首页 > 其他分享 >Q:以非root用户编辑定时任务报错You are not allowed to use this program(crontab)

Q:以非root用户编辑定时任务报错You are not allowed to use this program(crontab)

时间:2023-12-25 09:45:04浏览次数:26  
标签:use crontab 编辑 任务 program 报错 定时 root

编辑定时删除文件任务时报错

crontab -e 编辑定时任务时报错,如下图所示

问题原因:/etc/cron.allow中没有添加对应的用户名
解决办法:切换到root用户,在/etc/cron.allow中添加对应的用户名

编辑定时任务:crontab -e 

#每天中午13点,定时删除/var路径内30天以上的文件或者文件夹

0 13 * * * sudo find /var -mtime +30 -print0 | /usr/bin/xargs -0 -t -i rm -rf {} >> /dev/null 2>&1

 

标签:use,crontab,编辑,任务,program,报错,定时,root
From: https://www.cnblogs.com/wxp100/p/17925335.html

相关文章