scheduled script not executing as expected
Hi,
Greetings!! I wrote a small script to delete Jboss logs. Script is running fine and deleting log files when it is executed manually. But when I schedule it using cron Script is executing but logs are not being deleted. Unable to figure out what mistake I am doing. Please find the script below for reference. --------------------------------------------------- #!/bin/bash EXECDATE=`date +%d-%b-%Y,%l:%M%p` echo -e "\n Deleting Log files older then 3 days at $EXECDATE" >> /root/scripts/ dellogs.txt echo -e "\n##########################################################" >> /root/ scripts/dellogs.txt find $JBOSS_HOME/server/default/log -name "*.log.*" -mtime +3 -exec rm -f {} \; # End of script --------------------------------------------------- Also find the cron Entry 00 3 * * * /scripts/Jbosslog_del.sh Best Regards, KJ |
Quote:
Quote:
*BTW[1]: you marked this thread solved without presenting the solution. Doing that is called reciprocity and it's good for the whole of LQ, so please do. |
Hi,
Thanks for the reply Unspawn. Quote:
Quote:
Quote:
Best Regards, KJ |
Two things: check the mail of the owner of the crontab. Any errors cron will mail to its owner. Else try this cronjob instead:
Code:
#!/bin/bash -- |
First thing I see is this:
Code:
$JBOSS_HOME The easiest thing to do is to define JBOSS_HOME in the script ... the second thing to do if you are adventurous is to try placing the -l (dash el) option to the she-bang line of your script: Code:
#!/bin/bash -l |
Hi,
Greetings!! Thanks unSpawn and tonyfreeman for the suggestions. Sendmail service was stopped so I could no receive any mails from cron. After restarting I could found out that script was trying to find in /server/default/log path instead of $JBOSS_HOME/server/default/log. I updated the script as per tonyfreeman suggestion and it was working fine. Best Wishes, KJ |
All times are GMT -5. The time now is 11:06 AM. |