Hello there! As the title says, I would like to know if it's possible to set two different "daily" cron jobs. I have some lights/screen that I want to be turned on by certain time and then off at certain time. I've the scripts working from the terminal, but I want to set it to run daily at specific times
Thank you in advance!
@DanielSSilva
crontab -u root -e
There enter something like:
0 18 * * * /path/to/script <option to turn lights on>
which would lead to lights turned on at 18:00.
Reference: https://manpages.debian.org/stretch/cron/crontab.5.en.html
I forgot to mention that the script must be executed as root, more specifically this script sudo nano examples/strandtest.py
taken from here
@DanielSSilva
I forgot to mention that the script must be executed as root
Therefore I used crontab -u root -e 馃槈, crontab -u www-data -e would enable to add scripts, that need/wanted to start by www-data (e.g. necessary to run ownCloud/Nextcloud occ command).
Every user has its own crontab.
So then your line to add would be:
0 18 * * * /full/path/to/example/strandtest.py
right... that's what i've also tried but with no luck. Trying to debug the cause but without luck. I'll set the logs to full
@DanielSSilva
Ah sorry, it's a python script, so the command is at least python /full/path/to/examples/strandtest.py or even PYTHONPATH="/full/path/to/lib.linux-armv7l-2.7" python /full/path/to/examples/strandtest.py or something like this according to your link.
Another option is to utilize systemd/timers (man page). I have used them for something similar before.
Jep, systemd timers/services allow much more flexibility and you can add certain conditions and more. Needs just a bid more reading in order to configure them properly.
@DanielSSilva
Were you able to get your python script running via cron?
Yes I did :) There was also a misunderstanding on my side because i've set it as 1 * * * * * and thought it would run every minute, instead it runs only at the first minute each hour...
It has been fixed. Thank you :D
Marking as resolved. Please reopen if required.
Most helpful comment
Yes I did :) There was also a misunderstanding on my side because i've set it as 1 * * * * * and thought it would run every minute, instead it runs only at the first minute each hour...
It has been fixed. Thank you :D