Problem In Scheduling with Crontab on RHEL 4
Hi,
I am Scheduling a Shell Script using Crontab. But its not working. The Scripts actually deletes files after 12:00 PM at night that has been created during day time. Shell Scripts is :- File name- delete_old.sh #! /bin/bash cd /home/52222Setup/Check day=`date | cut -d" " -f3` for var in `ls -lh | awk '{print $6 " " $9 " " $7}' |grep -v " "$day | cut -d " " -f 2` do if [ "$var" == "delete_old.sh" ] then echo $var Not Deleted else if [ "$var" == "dt.sh" ] then echo $var else echo $var rm -f $var fi fi done I have scheduled it using following command in crontab @daily /home/52222Setup/Check/delete_old.sh >dev/null & or */1 * * * * /home/52222Setup/Check/delete_old.sh >dev/null & But it is not deleting files. I have noticed that crontab calls the scripts but it does not delete the file. Nothing is printed in spool mails as well. When i run this script manually, it works fine. Please help. Regards, Raghuvendra Kumar |
Have a look at:
http://www.linuxquestions.org/questi...3/#post2869197 What is stated there for "grep" would also apply to "awk" and other commands you're using. |
Quote:
PATH=/bin |
I'd also point out there's no need to put the process in the background when running from cron.
Also, why run it every minute? There's a lot of load on the system creating a whole new process env each time. Use a daemon instead if you really need to process every minute. |
Quote:
Thanks for your advice. I will do that. |
All times are GMT -5. The time now is 03:12 AM. |