This is my first crontab file. its work fine to execute logDHT.py
but will it work if i just add this line of code under the last line of my crontab? The line of code that i want to add:
* * 1 * * pi /usr/bin/python /home/pi/Sensors_Database/checkDB.py
My First Crontab:
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
1 * * * * pi /usr/bin/python /home/pi/Sensors_Database/logDHT.py
My goals is running 2 script at different time, with logDHT.py
running every minute, and checkDB.py
running every day.
Is pi /usr/bin/python /home/pi/Sensors_Database/checkDB.py
how you normally run the script if you were to run it from CLI?
Here is an example from my own crontab:
0 * * * * ~/.duckdns/duck.sh >/dev/null 2>&1
0 * * * * python ~/flagstatus.py >/dev/null 2>&1
As you can see, the first line is a bash script, and the second line is a python script. If I were to run my flagstatus.py
script from the command line, this is exactly what I would type in: python ~/flagstatus.py
and that's exactly what goes into crontab. The >/dev/null 2>&1
part at the end just tells cron that I don't want any output (ie no logs, etc). It's optional, just depends on if you want cron to create logs/send messages about the scirpts output.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.