[SOLVED] script+crontab
Hello,
I need help please. One of my script don't execute itself using crontab although it works manually. => /var/log/cron /var/log/cron show these 2 lignes at sheduled time May 26 09:59:01 COMPUTER crond[26439]: (root) CMD (/usr/local/bin/script) May 26 09:59:01 COMPUTER crond[26438]: (root) MAIL (mailed 77 bytes of output but got status 0x0001 ) When i launch it manually the job is done and a third line appears : May 26 10:15:01 COMPUTER crond[27784]: (root) CMD (LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok) I am root and i use crontab -e to modify the crontab. Root is the owner of the script and rights are ok => The script is : #!/bin/bash nas1=10.91.0.198:/mnt/NAS1 mnt1=/media/nas20091 if mount.nfs $nas1 $mnt1 then rsync -rltDv --del --ignore-errors --force /home/ $mnt1/SLR/script/ > /var/log/nas/rapport_script_du_`date +\%d-\%m-\%y`.log umount $mnt1 else echo echec fi => crontab -l :* #comments 23 30 * * 1,3,5 /usr/local/bin/script service crond is ok and restarted*after each modification, crontab is ok i tested it with others scripts. it is a centos 5.2 ps : sorry for my english, i am french |
What are these * in your script ?
Code:
#!/bin/bash |
modified, bad paste from openoffice. The're just spaces.
|
1. Redirect the standard error and standard out to a file to see for any possible error.
Modify your crontab entry to Code:
23 30 * * 1,3,5 /usr/local/bin/script >> /tmp/script.out 2>&1 3. It is a good practice to use absolute path to commands specially when the script is expected to be run via crond |
1. /usr/local/bin/savenas1lumeve: line 6: mount.nfs: command not found
echec 2. yes, i checked the result after this. => i don't understand the result (mount.nfs: command not found), do i need something more to launch it by crontab although it works when i launch the script directly ? |
Quote:
Code:
export PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin |
I added this line at the beginning of the script and it works.
thanks a lot ! ;) |
All times are GMT -5. The time now is 05:25 AM. |