Reputation: 327
what happens to my script in python that does not run through crontab every minute. My script has execute permissions and then calls two other scripts in python.
This is the content of my crontab (#crontab -l):
*/1 * * * * /usr/bin/rsm/samplesMonitor.py
Thank you guys.
Upvotes: 2
Views: 7421
Reputation: 116948
Check /var/log/syslog
for errors.
DIAGNOSTICS
cron requires that each entry in a crontab end in a
newline character. If the last entry in a crontab is
missing a newline (ie, terminated by EOF), cron will
consider the crontab (at least partially) broken. A
warning will be written to syslog.
Update: According to your log message, the script is running but returning an error code. Cron will email you the output, if you have a mail agent installed.
Try either:
apt-get install exim4
change your cron line to log to file, like so:
* * * * * /usr/bin/rsm/samplesMonitor.py 2>&1 >> /tmp/script.log
Update 2: I re-read your question and it acurred to me that maybe you are running into python import issues. You say that your script calls two other scripts. My suggestion would be to test running your script from /
. Python has a default behavior to find imports in the current working directory, so make sure your script can run from any path location.
In the crontab, you can set the starting working directory by calling your script from within another shell process. For example:
bash -c "cd THE_WORKING_DIR;/usr/bin/rsm/samplesMonitor.py"
Upvotes: 4
Reputation: 116948
If you want it to run every minute, just do this
* * * * * /usr/bin/rsm/samplesMonitor.py
Upvotes: 0
Reputation: 12479
It should be */1
instead of *\1
(forward slash instead of backslash). Also, make sure the path is correct; there usually are no subdirectories under /usr/bin.
Upvotes: 0