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!

Cron Issues 3

Status
Not open for further replies.

harpal

Technical User
Oct 3, 2001
115
GB
I have set up a cron to run a couple scripts which ftp some files over to our comapines remote sites the problem is that everything seems to be in order but the ftp does not take places even though the cron has kicked off the job I can see that through the ps -ef command. When I manually run the scripts the ftp takes places. this is driving me insane

Any Ideas
 
It's possible that cron isn't picking up the correct environment to enable the script to run properly. You could try either setting this explicitly within the script or by having your cron call the correct environment using the:

su - <user> -c &quot;<command>&quot;

command strucure. There are several examples of this type of thing in various threads on this site. Do a search for cron and you may find what you're looking for. HTH.
 
Ken how do I know what $ENV the cron is kicking off the job in
 
Harpal,

strictly speaking, cron doesn't have an environment, so anything that runs in it has to either set one explicitly or inherit another. Things like $PATH variables etc need to be correct and to match the requirements of the job in order for it to work.

Have a look at thread80-62570 for a discussion. Hope this helps.
 
Ken,

I ahve tried everything here is the line as appears in my cron.


24 12 * * * /home/crms/bin/kbridge-crms-transfer.ksh > 2>&1 /tmp/out.log

This is not a root Cron but the cron of a group set-up called CRMS.

I was havin a look at he SU command with the -c flag would I have to edited that in my script or could I simply put the line into my cron directly
 
Harpal, the following is a sample of one of our root cron jobs, which I hope will give you some idea:

0 7 * * 1 /bin/su tech -c &quot;ksh /home/tech/bin/info.s&quot;

In this way, root su 's to tech and runs the script within the quotes. It's a good idea to put . /<user_home>/.profile early in your script so that the user's .profile is executed and the environment set. Note the space between the . and the / at the beginning of this command - this is important. As an afterthought, do check whether you have files called cron.allow and cron.deny in /var/adm/cron. If you do, check that the user trying to execute the cron is included in cron.allow, but not in cron.deny.

Hope this makes sense. Good luck.
 
Ken,

this issue is now closed.

cheers mate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top