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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question in scheduling job. 1

Status
Not open for further replies.

EdRev

Programmer
Aug 29, 2000
510
US
I have been reading previous posts about cron, but still was unable to understand how to do it.

I have an ftp job that I launch like this:

/usr/public/bin/ftp.proc tgsys ftpfiles.txt xx

I didn't write the ftp.proc, but I guess it takes in 3 param
tgsys is the target system, ftpfiles.txt contains the ftp commands (put source_file target_file).

How can I schedule this ftp job using cron command?
Also, I would want the job to loop until it finds the source_file. How do I do it.
 
If you want the job to loop until it finds the source file, it would probably be better if you write a script that looks for the source file and when it finds it runs the ftp.proc routine and exits.

Then, schedule the script to run in cron. Alternatively, you could schedule the job to run every 5 minutes, but I doubt that is something you want.

Use the crontab -e command and edit the file the appears to add a line something like this:

55 23 * * * /home/utility/bin/ftp.sh > /dev/null 2>&1

This runs the script every day at 11:23 p.m. and sends stdout and stderr to dev/null.

Here is something I put in my crontabs so I don't have to look up the fields in the crontab all the time:

# Crontab format:
#
# minute (0-59)
# | hour (0-23)
# | | day of the month (1-31)
# | | | month of the year (1-12)
# | | | | day of the week (0-6 with 0=Sunday)
# | | | | | commands


The first field is minutes, second hours, etc.

I hope this helps.
 
You also need to consider that cron operates in a minimal environment of it's own, so it's necessary to tell it about any PATH variables etc that are necessary to run the job. I usually export these within the calling script as suggested by bi. The crontab format header suggested by bi is excellent, btw, I think that's probably where I got the idea in the first place. HTH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top