
5

脚本添加的 cron 任务不执行,要运行 crontab -e 保存一次才行。
source link: https://www.v2ex.com/t/805504
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

脚本添加 cron 内容如下,用户名为 test
#!/bin/bash
USER=test
sudo tee -a /var/spool/cron/crontabs/$USER >/dev/null <<'EOF'
*/5 * * * * echo a >> /tmp/test.txt
EOF
sudo chown -R $USER:crontab "/var/spool/cron/crontabs/$USER"
这里添加后即使 cron 服务已经启动,但还是不执行,要用户运行 crontab -e 保存一次才行
是添加的方法不对吗?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK