
查看cron的运行状态
service cron status
参数说明
-e:编辑某个用户的crontab文件内容。如果不指定用户,则表示编辑当前用户的crontab文件。
-l:显示某个用户的crontab文件内容,如果不指定用户,则表示显示当前用户的crontab文件内容。
列出crontab文件
crontab -l
编辑crontab文件
crontab -e
20 9 * * * /bin/bash -l -c 'cd /home/webuser/Documents/rails_proj && git checkout branch_name && bundle exec rails runner -e production script/ruby_script.rb '
/bin/bash -l -c 说明
/bin/bash -l -c
man bash
-c `string` If the -c option is present, then commands are read from string.
If there are arguments after the string, they are assigned to the positional parameters, starting with $0.
-l Make bash act as if it had been invoked as a login shell (see INVOCATION below).
参考文章
https://linuxtools-rst.readthedocs.io/zh_CN/latest/tool/crontab.html
网友评论