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 job

Status
Not open for further replies.

nkm

Programmer
May 27, 2001
45
US
Hi all

I am trying to set a cron job for writing its ouput to a log file.

If I do not redirect the O/P having set it as a cron job then I get the O/P message as a mail.

And even if I run it off the command prompt it is successfully able to redirect the output to a file. But if I set it as a cron then it desn't get executed
Am I missing something here

Please help!!!

 
I think that you will have to look hard at the environment variables being used.
It is probable that the shell under which you are running the cron job does not have the same environment variables as the one that you are testing manually.
To solve try saving your successful environment as a file and calling it from the beginning of your script to set the variables before the guts of the cron job executes.

To stop the mail try redirecting the standard output to /dev/null by adding this to the end of the appropriate line in the crontab;
>/dev/null 2>&1

It could work. Ian

"IF" is not a word it's a way of life
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top