I know there are a million webpages on how to use Crontab however i have just spent a whole day trying to get a a script to run on a schedule. Looks simple and i do exactly as per the samples and it will not work.
I have tried
*****python /home/paul/Documents/PwrOut.py
(user is Paul - me) It won’t even save
Says “/tmp/crontab.P3Vb5e/crontab”:25: bad command
errors in crontab file, can’t install."
***** python /home/paul/Documents/PwrOut.py
Tried with and without space before ‘python’ and in front of ’ /home’. Tried without python. Tried with ‘usr/bin/python’. Made script executable. Tried without ‘python’. Tried without ‘Documents’. Tested script in Terminal works fine.
Thinking there is something fundamental i am not seeing or aware of.It is really stressing me out because it should be so simple according to everyone.
HELP please.
Part of the problem solved.
Stumbled on an old post that had the fix. Crontab required two blank line returns after the code and then it will save. If it doesn’t have this it will not save.
Also, I managed to look at the /var/log/syslog and the @reboot commands are working.
However NONE of the other commands with ***** timed format schedules are work.
Same syntax apart from the execution time part. The path works for the @reboot so should work for the ***** instructions also . It is puzzling? Any ideas anyone?
Hi @Paul264093,
Sorry to hear you’re having issues.
One thing that may be causing issues is not having a space between the * characters.
All the examples I’ve seen have it. Might be a variable to eliminate.
Something that would be worth checking is testing the commands in terminal to make sure they don’t have any issues.
Hi Aaron, thanks for your suggestions.
GOOD NEWS… I managed to solve the crontab problem . After delving through more old posts someone suggested line returns.
Turn out the script needs a ‘line return’ right on the end of the line of code - directly after the code… Apparently Crontab ignores the line all together if it doesn’t have a return. Similar to it not saving without having and empty line after the last line of code. Turns out Crontab is very fussy.
And for good measure I also put a space between each of the * , as you suggested.
I ran an every minute message script to test and also checked with ‘sudo service cron status’.
It all seems to be working. Thanks for your input.
Glad you were able to get it all working