linux——crontab定时任务
2021-03-03 本文已影响0人
小T呀
命令行中输入crontab -e
编辑crontab的任务内容
在crontab中写了如下的一个任务:
0 8 * * * echo "Hello"
初次运行将出现
no crontab for 用户名 - using an empty one
crontab: installing new crontab
是正常的。但单纯echo,从屏幕上看不到任何输出,因为cron把任何输出都email到系统信箱了/var/spool/mail/用户名(LINUX的邮件提示功能),可在root及其组用户权限下查看。
可以将输出重定向到另外一个标准输出文件中,如
0 8 * * * echo "Hello" >> /tmp/test.txt
*/2 * * * * date>> /tmp/test.txt

46 10 * * * mail XXX@163.com< /tmp/test.txt
