如何使用命令提示符设置 crontab?

1 cron

如何使用命令提示符在服务器中设置 cronjob/crontab。提供示例命令或示例链接。

小智 6

crontab -e
Run Code Online (Sandbox Code Playgroud)

使用默认编辑器以交互方式编辑 crontab

crontab <file>
Run Code Online (Sandbox Code Playgroud)

用给定文件的内容替换 crontab

如果您不带参数运行 crontab,则会显示一般用法帮助,例如:

crontab: usage error: file name must be specified for replace
usage:  crontab [-u user] file
    crontab [-u user] { -e | -l | -r }
        (default operation is replace, per 1003.2)
    -e  (edit user's crontab)
    -l  (list user's crontab)
    -r  (delete user's crontab)
    -i  (prompt before deleting user's crontab)
Run Code Online (Sandbox Code Playgroud)

通过“man crontab”可获得更多帮助。