I've been running a shell script every minute between Monday and Friday between business hours, and thought it was running fine, as I can see it when I use the "crontab -l" command. The script calls a piece of Java code which checks certain conditions in a postgresql table, and if those conditions are met, it writes out to another table. The script is in the following directory on our Linux server.
/var/lib/tomcat7/webapps/sh
So lets say it is called "test.sh", should my cronjob look like this this:
* 08-18 * * 1-5 /var/lib/tomcat7/webapps/sh/test.sh
ie, it should run every minute of every day from Monday to Friday between 8 am and 18:59 pm. I just tried testing it by adding dummy data to the postgresql table so that the other table should have been written to and nothing happened. However when i ran ./test.sh manually from the command line it worked fine. The issue seems to be with my cron. If I type:
grep CRON /var/log/syslog
I can see that it has run every minute today. The output looks like this
Nov 25 12:38:01 webserver CRON[11868]: (ubuntu) CMD (/var/lib/tomcat7/webapps/sh/test.sh)
Nov 25 12:39:01 webserver CRON[11888]: (ubuntu) CMD (/var/lib/tomcat7/webapps/sh/test.sh)
Nov 25 12:40:01 webserver CRON[11953]: (ubuntu) CMD (/var/lib/tomcat7/webapps/sh/test.sh)
Nov 25 12:41:01 webserver CRON[11953]: (ubuntu) CMD (/var/lib/tomcat7/webapps/sh/test.sh)
Nov 25 12:42:01 webserver CRON[11985]: (ubuntu) CMD (/var/lib/tomcat7/webapps/sh/test.sh)
etc.. However after I altered the data in the postgresql table this did not seem to have any effect. It's as if the script isn't actually running. Although it runs perfectly when I run it manually from the command line. Has anyone ever experienced this sort of thing with cron jobs, or have any advice as to why this might be happening? Any assistance would be appreciated. Thanks in advance!