I've got a python file called color.py that if I run using python color.py will work on a file. I can run it okay from the terminal but it doesn't get called from crontab. I've used chmod +x color.py to try and make it executable.
The py file does start with
#!/usr/bin/env python
and the cron command is
*/1 * * * * /root/images/color.py
1 Answer 1
First check if following command works by running as user root (su or sudo):
/usr/bin/python /root/images/color.py
If that works, then edit crontab to:
*/1 * * * * /usr/bin/python /root/images/color.py
How do you check if the cron job succeeds or not?
answered Jul 14, 2017 at 22:38
anneb
5,7982 gold badges30 silver badges27 bronze badges
Sign up to request clarification or add additional context in comments.
11 Comments
Samuel M.
the command works and it deletes a file(s) that's how I know the task's done
anneb
do you reference the file to be deleted by its full path? Not delete 'myfile' but something like delete '/root/images/myfile' ?
Samuel M.
using os.remove(filename) @anneb
anneb
is ' filename' full path or not? If it is 'myfile' it will only work if you explicitly change the working dir to the directory containing the file, if it is '/root/images/myfile' then that should be ok
Samuel M.
I've edited to this been more than a minute but the file still is there, I know if I run python color.py it's going to colour the image make a new file and delete the old one.
|
lang-py
/root/images/color.py?/root/images/color.py?