systemctl status cron # Ubuntu/Debian:ml-citation{ref="2,3" data="citationList"} systemctl status crond # CentOS/RHEL:ml-citation{ref="2,8" data="citationList"}
若服务未启动,需执行 systemctl start cron
或 service cron start
23。
//测试任务, 表示每1分钟执行一次 * * * * * /path/to/script.sh >> /tmp/cron.log 2>&1 # 将标准输出和错误输出写入文件
3. 如果提示权限不足(command not found), 则执行以下代码进行授权
chmod +x myshell.sh && ./myshell.sh
4.启用 cron 日志
sudo nano /etc/rsyslog.d/50-default.conf # 取消注释 `cron.* /var/log/cron.log` // 重启日志服务 sudo systemctl restart rsyslog cron # 应用配置变更
4. 下面代码则检查计划任务的执行日志
tail -f /var/log/cron.log
本文为宁若水!原创文章,转载无需和我联系,但请注明来自[若水]博客 www.lalaya.net