简体   繁体   English

定期运行shell脚本o运行raspbian的raspberry pi 3

[英]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. 我有一个Shell脚本,其中包含运行特定python脚本的命令。 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 我正在使用树莓派3,正在运行raspbian,并且python脚本在python 2中

Use cron/crontab. 使用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 ): 格式为( 在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的用户。 Crontab will not pay attention to how, or if, your script completes. Crontab不会关注脚本的完成方式或完成方式。 In case you need more control, like not to start another until the previous still going, you'd have to look for alternatives. 万一您需要更多控制权,例如在上一个操作仍然进行之前不启动另一个操作,则必须寻找替代方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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