1.启动cron工具[ps:使用root权限] centos启动cron两种方式 a) /etc/init.d/crond start b) service crond start ubuntu启动cron两种方式 a) /etc/init.d/cron start b) service cron start(推荐) 2.添加定时任务[每个整点执行ls命令] centos crontab -e命令打开文件 添加一行:0 * * * * ls ubuntu crontab -e命令打开文件[ps:
如何在Ubuntu上启动一个定时任务,使得可以定时删除机器上的日志 首先, #查看cron状态 service cron status 如果提示没有安装 #安装cron服务 apt-get install cron 如果提示正在运行 #编辑当前用户的计划任务文件crontab -e 弹出编辑界面,如下文件,加入最后一行代码,意思是每两分钟向/home/cron_test文件写入一次Hello World # Edit this file to introduce tasks to
crontab -e 写入: # at a.m every week with: # * * tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab() and cron() # # m h dom mon dow command * * * notify-send 'take a break now!' */30 * * * * export DISPLAY=:
今天研究了下ubuntu里的crontab内置指令.这是设置定时执行脚本任务的指令,我先测试了下最基础的执行. 第一次使用crontab 时,会出现 no crontab for root - using an empty one “Select a editor ......”下面有几个选项,就是叫你选择编辑器.(选vim)就可以了,我选的第三个. 但是如果你选错了,就可能会遇到点麻烦,没有办法正常编辑,crontab -e. 怎么办? 执行这个命令:select-editor (针对cro