Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of Cron 1

Status
Not open for further replies.

salimwng

IS-IT--Management
Mar 11, 2002
134
MU
Platform: SCO Unix Sys/V

Could anybody help me how to use cron or syncronising data files on 2 Unix servers with TCP/IP installed on it. I would prefer the syncronisation ( or copy ) to be made regularly 2 times a day. One at noon and the other one at 20:00.

 
You need to place something like the following in your crontab:

00 12,20 * * * ksh <script you wish to run>

This will run the script every day at 12:00 and 20:00. From the man page, the meaning of each entry is as follows:

&quot;The crontabs files consist of lines of six fields each. The fields are separated by spaces or tabs. The first five are integer patterns that specify the minute (0-59), hour (0-23), day of the month (1-31), month of the year (1-12), and day of the week (0-6, with 0=Sunday). Each of these
patterns may contain:

o a number in the (respective) range indicated above

o two numbers separated by a minus (indicating an inclusive range)

o a list of numbers separated by commas (meaning all of these numbers)

o an asterisk (meaning all legal values)&quot;

I assume you'll be using ftp, rcp or similar to do the copy? If you need help with these, post back, or do a search on these forums - there are many examples of various methods of doing this. Hope this helps.
 
Thanks a lot KenCunningham.

It's working perfectly.

I would like to know if it is possible that a log be generated when cron is executing that daily script and ALSO about the ftp ( by using NETRC ) of file to another Unix server.

Above are working just fine, it's only about the log which i would like to keep track....If something getting weird later, i would be able to trace it out.

Looking forward to read from you,
Thanks again & kid regards.
Salim
 
Glad to help Salim. To generate a log, you can send any output generated stdin and stderr to a file by including something like:

[path of log file to write to] 2>&1

at the end of the crontab entry. An alternative is to include redirection to a log file within the script itself, so that you are getting a report that the script has reached various stages successfully. HTH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top