Answer the question
In order to leave comments, you need to log in
Why doesn't Crontab work on CentOS 7?
Hello! On CentOS, I call as root and crontab -e
create a new task. The log file shows that the task was completed, but in fact the script did not start. When I make changes to /etc/crontab and restart the service, service crond restart
the task successfully completes. What is it? Am I cursed?
Answer the question
In order to leave comments, you need to log in
which python3.6
And insert the resulting full
CRON path DOES NOT have a PATH VARIABLE by default, as a result, it is not able to determine where the binary is
The log file shows that the task was completed, but in fact the script did not start
Excuse me, why did you decide that crontab -e
/etc/crontab rules? This command edits the root personal crontab, which lies somewhere in the wilds of /var (where to look for crowbars, but maybe /var/cron/tabs or something like that)
. then.
I came across this more than once, so I just scored on crontab -e and just edit /etc/crontab if necessary.
Use systemd. Recently I came across an interesting article on Habré - using systemd timers instead of cron jobs
If there is a User in the system and you work in his environment, then when you enter into the Terminal:
crontab -e
the task is written to a file:
/var/spool/cron/имя_пользователя_в_системе
it will not work.
It is necessary:
sudo crontab -e
and then the task is already written to the file:
/var/spool/cron/root
and so it will work.
And be sure to do it afterwards:
sudo /etc/init.d/cron restart
You can immediately add a task in the Terminal, without opening the editor and manual input, in two ways:
1. If the task has never been added to the system in crontab at all, for example:
echo -e '0 */8 * * * php /opt/acelist/as.php /opt/lists/as' | sudo crontab -
and in this case there is no need to reload cron. sudo sh -c "echo '0 */8 * * * php /opt/acelist/as.php /opt/lists/as' >> /var/spool/cron/crontabs/root"; sudo /etc/init.d/cron restart
in this case, the task is added as a new line to the file and a cron overload is already needed, which is present in the code. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question