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

1/2 of crontab edit not working

Status
Not open for further replies.

Natalie

Programmer
Jun 6, 2000
29
US
Hello.

I edited our crontab using "crontab -e". I changed 2 lines. One works, and one doesn't.

Does anyone know why?

Thanks,
Natalie
 
0 23 * * 1-5 /u/bin/onlinebkup2.sh
0 8 * * 1-5 /u/bin/backrept2.sh

The first one works, the 2nd doesn't. However, I can manually run backrept2.sh just fine. It's a script that emails me a file. One point is that it emails me from the login of 'system', whereas another script in the crontab emails me from 'root'.

Thanks,
Natalie
 
Have you set the environment (particularly the PATH statement) in the script? Usually, when you can run a script successfully from the command line, but not from cron, not having the correct environment set in the script is the first place to look for the failure.

How was user 'system' created (or is it user sys?)? when you run the script manually, have you signed in as 'system' or done an su - system? Have you tried the script with root doing the emailing?
 
This script works from crontab and sends the email from root:
df -k>fs.txt
mail -s FileSystems -c &quot;email1@lala.com email2@email.com&quot; email3@email.com<fs.txt

This one doesn't, but when I run it manually, it sends the email from system:
cp /tmp/ONLINEBKUP /u/bin/ONLINEBKUP

mail -s Backup-Report -c &quot;email1@lala.com email2@email.com&quot; email3@email.com<ONLINEBKUP

When I run it manually, I log in as system, and su to root. When I changed the crontab, I did the same thing. Do I need to physically be at the AIX console logged in as root?

Natalie
 
I had the same problem before, and I believe it to be an environmental problem. However, with 80 SP nodes I didn't feel like finding the answer so I cheated and wrote a daemon process to run it.

 
No. you don't need to be at the console logged in as root. But make sure when you do become root you use su - root so you invoke root's .profile and get root's environment (including PATH). That may be why the email comes from user system rather than root when you ran it manually.

Who do you want to run the scripts: root or system?
 
I would bet my life that I had su'd to root when I edited the crontab, but I could be wrong. I always su to root when I'm on this server.

I just edited it again as root. I didn't change anything, but I saved it again from root. We'll see on Monday morning if the script runs.

Have a good weekend!
Natalie
 
If that doesn't work then recreate the crontab file from scratch. I have had that work before, too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top