简体   繁体   中英

Periodically run shelll script o raspberry pi 3 running raspbian

I have a shell script which contains a command to run a particular python script. I want the script to run automatically every hour. Is there any tool that can help me with this? I am using a raspberry pi 3, running raspbian and the python script is in python 2

Use cron/crontab. You can find usage here .

Type from your raspberry-pi console:

crontab -e

This starts an editor of so scheduled tasks. The format is ( after adminschoice.com ):

*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

So, in your case, the file should look like:

0 * * * * /path/to/your/script

Note the runtime permissions will be as the user that edited the crontab. Crontab will not pay attention to how, or if, your script completes. In case you need more control, like not to start another until the previous still going, you'd have to look for alternatives.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM