A
A
Alexander2019-12-14 15:22:59
linux
Alexander, 2019-12-14 15:22:59

Cron has stopped working on the server, what could be the problem?

Good afternoon, cron stopped running jobs completely. I decided to try to create a new file and register everything. Got this file

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin/
# m h dom mon dow user  command

*  *    * * *   root    touch /root/home/1.txt
#

For the test, I decided to give a task so that it creates a file in a specific folder, but absolutely nothing happens, I edit the task through the sudo crontab -e command. If I manually execute touch /root/home/1.txt, then the file is created.
Who knows what could be the matter?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
L
Lev Zabudkin, 2019-12-14
@AlexMine

Apparently the service is not running.
what does service cron status
say?
/etc/init.d/cron status
says what?
If ubuntu/debian then:
sudo systemctl enable cron
to always start the service.
And run it manually:
service cron start
/etc/init.d/cron start
If you have older versions, then there may not be cron, but crond

V
vreitech, 2019-12-14
@fzfx

do
check in a minute if the cron worked.

Z
zersh, 2019-12-15
@zersh

Specify the full path to the touch command

S
slalomjohn, 2021-03-30
@slalomjohn

At the end of the file, add at least 2 empty lines - this is not a bug, this is a feature.
If there are not 2 empty lines at the end of the file, then the file will not be executed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question