This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
Just do:
开头的0表示在第0分钟运行。 (如果是 *,则脚本将在每隔一小时内每分钟运行一次。)
不要忘记,您可以检查系统日志以查看它是否真正运行过!
Just do:
The 0 at the beginning means to run at the 0th minute. (If it were an *, the script would run every minute during every second hour.)
Don't forget, you can check syslog to see if it ever actually ran!
该行应为:
或
The line should read either:
or
答案来自 https://crontab.guru/every-2-hours。这很有趣。
The answer is from https://crontab.guru/every-2-hours. It is interesting.
0 */1 * * * “每小时过 0 分钟。”
0 */2 * * * “每 2 小时 0 分。”
这是为每个小时设置 cronjobs 的正确方法。
0 */1 * * * “At minute 0 past every hour.”
0 */2 * * * “At minute 0 past every 2nd hour.”
This is the proper way to set cronjobs for every hr.
要进入 crontab :
将其写入文件中:
示例:
0 */2 * * * python ec2-user/home/demo.py
并确保在最后一个 cron 后保留一个空行crontab 文件中的作业
To Enter into crontab :
write this into the file:
Example :
0 */2 * * * python ec2-user/home/demo.py
and make sure you have keep one blank line after the last cron job in your crontab file
首先执行 crontab -l
查看您现有的 crontab 和作业
如果你什么都不做,那就做
crontab -e
检查你的编辑器可能是 VI 或 nano 或类似的东西..按“i”进入插入模式,
命令应该像
(cron 表达式)[空格](家中的程序执行地址)[空格](家中的脚本地址)
示例
(0 /2 * * * /conda///bin/python3 /< /strong>//USERNAME/TEST_PYTHON_SCRIPT.py>>execution_log.txt)
一旦你正确放置了命令
通过保存文件退出编辑器
对于纳米-> Ctrl + X
对于 vi -> :wq!
使用一些电子邮件/打印声明检查您的脚本。
first do crontab -l
to see your existing crontab and jobs
if you don't anything then do
crontab -e
check you editor maybe VI or nano or anything like that.. go to insert mode by 'i',
command should be like
(cron expression)[space](program execution address from home)[space](your script address from home)
example
(0 /2 * * * /conda///bin/python3 ///USERNAME/TEST_PYTHON_SCRIPT.py >> execution_log.txt)
once you have your command correctly placed
exit the editor by saving the file
for nano -> ctrl + x
for vi -> :wq!
check your scripts with some email/print statement.