在root目录新建 test.sh 测试文件:
#!/bin/bash
# 每隔一分钟在/root/testFile文件中写入最新时间 /usr/bin/echo `date +'%Y-%m-%d %H:%M:%S'` >> /root/testFile
crontab -e
# 新建定时任务
*/1 * * * * /bin/bash /root/test.sh
注意事项:
!!! crontab中的命令、文件名要使用绝对路径,
!!! 如果是roote用户执行,第五个*后面不要加用户名root ,否则会报 “CMDOUT (/bin/sh: root: command not found)”