自从服务器迁移以后,自定义的代码仓库备份脚本一直没有执行过,可是原来机器的环境已经不存在了,只能自己摸索。虽然知道cron是用来实现定时任务的,但是一直不知道......
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
由于对脚本的认知有限,不能详细解释每个命令的含义。在第10行,同样定义了文件内容的格式。可以看到比使用crontab -e命令时,多了一个user。它表示了执行命令的用户,如果是root,就表明是系统用户。于是,我加了如下一行:
3 * * * * root /home/meng/hello.sh
然后保存
编辑特别推荐:
linux面试题参考答案
最简便的MySql数据库备份方法
Unix动态库和静态库比较
2/2 首页 上一页 1 2 |