crontab reports errors /var/spool/cron: Permission denied and -bash: chattr: command not found

crontab reports errors /var/spool/cron: Permission denied and -bash: chattr: command not found

1. The first situation

When modifying the scheduled task under centos7crontab -e, the console outputs "crontab: installing new crontab", indicating that the task was added successfully and the corresponding task will not be executed for the next three minutes. tasks, so when debugging the timer, these three minutes must be taken into consideration. If the execution time is within three minutes, the corresponding task will not take effect. The reason (using crontab -e to write requires waiting 3 minutes for the effect to appear). If this is the case, it does not fall into the following problems mentioned in this article.

crontab: installing new crontab
/var/spool/cron/#tmp.localhost.localdomain.XXXXPRusYN: Permission denied
crontab: edits left in /tmp/crontab.Kglowi

Insert image description here

2. The second situation

It is normal to view the cron directory under Enter/var/spool, but there is no permission to create files in cron.
You can try to edit a test file with vim in the /var/spool/cron directory first to see if it can be saved in the cron directory. If it cannot be saved, it will prompt a permission issue. Then maybe there is something special about the directory, and the root user is also restricted

1. Check if there are any special attributes

lsattr /var/spool/cron/

2. Remove special attributes

chattr -ai /var/spool/cron

3. Edit the scheduled task again:

crontab -e

4. Saved successfully

crontab: installing new crontab

3. The third situation

The server has built a pagoda panel. In this case, you have to go to the pagoda interface to set up scheduled tasks, because the permissions are in the pagoda.

  • Generally, you can set the scheduled tasks in the navigation bar on the left side of the pagoda.

Insert image description here

  • If the above situation occurs, you need to go to Software > Pagoda System Reinforcement to remove the scheduled task reinforcement. After adding the scheduled task, you can start it back.

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_43576565/article/details/133809471