大网数据广告活动
服务器运维问答

Cannot add cron task

· 52CE 我爱测

I'm trying to add cron task to renew my certbot certificates everytime they are going to expire, but I can't seem to be able to do that. I used this command: crontab -e 0 12 * * * /usr/bin/certbot renew -quiet crontab: invalid op…

问题原文

原帖链接 · krystof18 · CC BY-SA 4.0

I'm trying to add cron task to renew my certbot certificates everytime they are going to expire, but I can't seem to be able to do that. I used this command: crontab -e 0 12 * * * /usr/bin/certbot renew -quiet

crontab: invalid option -- 'q'
crontab: usage error: unrecognized option
usage:  crontab [-u user] file
        crontab [ -u user ] [ -i ] { -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)

Also tried this: rontab -e 0 12 * * * /usr/bin/certbot renew --quiet And got:

crontab: invalid option -- '-'
crontab: usage error: unrecognized option
usage:  crontab [-u user] file
        crontab [ -u user ] [ -i ] { -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)

This: crontab -e 0 12 * * * /usr/bin/certbot renew -q

crontab: invalid option -- 'q'
crontab: usage error: unrecognized option
usage:  crontab [-u user] file
        crontab [ -u user ] [ -i ] { -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)

This: crontab -e 0 12 * * * -q /usr/bin/certbot renew

crontab: invalid option -- 'q'
crontab: usage error: unrecognized option
usage:  crontab [-u user] file
        crontab [ -u user ] [ -i ] { -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)

This: crontab -e 0 12 * * * --quiet /usr/bin/certbot renew

crontab: invalid option -- '-'
crontab: usage error: unrecognized option
usage:  crontab [-u user] file
        crontab [ -u user ] [ -i ] { -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)

This: crontab -e 0 12 * * * /usr/bin/certbot renew

crontab: usage error: no arguments permitted after this option
usage:  crontab [-u user] file
        crontab [ -u user ] [ -i ] { -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)

I also tried crontab -e 43 6 * * * certbot renew --post-hook "systemctl reload nginx" from this answer, but it threw:

crontab: invalid option -- '-'
crontab: usage error: unrecognized option
usage:  crontab [-u user] file
        crontab [ -u user ] [ -i ] { -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)

I don't know what else can I do. I use Ubuntu 20.04.

已采纳解答

原帖链接 · AllBlooming · CC BY-SA 4.0

You want to just run crontab -e and then hit Enter.

Then your crontab will appear in the editor that is configured in your environment.

In the editor, you can then add the line to the crontab that you want to add:

0 12 * * * /usr/bin/certbot renew -quiet

The problem is your trying to do two steps in one.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-07-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。