Basic Cron Job Help!
Hi Everyone,
I am trying to create a cron job that runs every 4 hours. This is what I put in my crontab file: 01 */4 * * * tester/home/tester/ff/python ff.py I get this error however /bin/sh: /home/tester/ff/python: No such file or directory All I'm trying to do is create a cron job that runs the command "python ff.py" every 4 hours. Can anyone help me here? Thanks I'm using Fedora btw. |
It wont work like that. Create a script under the home directory and make it executable, in that script call the python interpreter and script.
Code:
01 */4 * * * tester /home/tester/ff/myscript python ff.py Something like that. hth |
That won't work either as the file "tester" probably doesn't exist either. And, if /home/tester/ff/python is the path to the python interpreter, then it should work fine the way you are trying to do it. However, you have a path of "tester/home/tester/ff/python". Are you sure your error message isn't:
Code:
/bin/sh: tester/home/tester/ff/python: No such file or directory Try this instead: Code:
01 */4 * * * /home/tester/ff/python ff.py Forrest |
sorry, my mistake there should be a space in there i just copied it down wrong when posting this
it actually appears like this: /bin/sh: tester /home/tester/ff/python: No such file or directory I'll try lord-fu suggestion Thanks |
In my example tester is the "who" not a path.
Edit: forrest is correct though a user should have their own crontab if you are wanting to run jobs as that user. And on that note I have 666 posts, there goes my day :[ |
lord-fu & sbabcock23, I think the problem may be that you are trying to edit a non-system crontab entry with a system crontab entry format. Only the system crontab (/etc/crontab) uses the user field. The root crontab doesn't, and neither do any for normal users.
sbabcock23, If you are running "crontab -e" as root to edit the crontab, then there isn't a user field as this is the root user's crontab, not the system crontab. The entire line after the time specifications is treated as the command/options. If you are editing /etc/crontab directly, then you would use a user field. I typically leave this file alone and create per user crontab entris as it makes copying crontab entries from Linux to Solaris and back compatible. If you are running "crontab -e" as the tester user (what I suggest) then you will also not have a user field in the crontab entry. HTH Forrest |
That is correct forrest I was under the impression in the op example that this was the system crontab, therfore I left the user entry in my example. Sorry for any confusions.
And on that note I am above 666 posts, whew. |
Yeah, your post count was getting me a little worried.
:) |
hey, I got the cron to work except, in my python code I have file = open(filename, 'a') and python is throwing an error:
sys.stdout = open(logfile, 'a') IOError: [Errno 13] Permission denied: 'log.txt' but this works if I run it manually but not from the cron job. I added the cron job by using the command crontab -e. Any suggestions? Thanks |
Try using the full path to log.txt.
HTH Forrest |
yup that worked thanks!
|
All times are GMT -5. The time now is 03:56 PM. |