我是使用root 用户
权限是root
1 设置crontab
看看执行情况
crontab -e 编写root的crontab 内容设置为
* * * * * echo "root crontab test" >> /tmp/test.txt
观察运行的情况
观察运行的情况
2 crontab 的重启
sudo /etc/init.d/cron stop;
/etc/init.d/cron start
活在 /etc/init.d/cron restart
service cron restart
3. 查看当前到运行的定时到任务
crontab -l
4 编辑 定时任务
crontab -e
5 重新选择crontab编辑器
有时候在你执行crontab -e的时候如果你是第一次执行这个命令,那么它会让你选择编辑器,如果你选择了之后想更改编辑器的时候可以用 sudo update-alternatives --config editor 这样再重新选择编辑器,重新再选择就好了
Ubuntu 9.10 cron定时执行任务
cron,是一个Linux定时执行工具,可以在无需人工干预的情况下运行作业。
1. 关于crontab
在Ubuntu server 9.10下,cron是被默认安装并启动的。通过/etc/crontab文件,可以看到以下内容:
-----------------------------------------------------------------------------------------------------------------------
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `cront