2

My backup script works fine when executed manually; but nothing runs from crontab. I am running Fedora 35 Workstation.

The crontab editor works:

$ crontab -e 

The cron daemon is not running. Each of these commands has no output:

$ pgrep cron $ pgrep crond $ pidof cron $ pidof crond 

My attempts to start cron:

$ whereis cron cron: /usr/share/man/man8/cron.8.gz $ whereis crond crond: /usr/sbin/crond /usr/share/man/man8/crond.8.gz $ sudo service cron start Redirecting to /bin/systemctl start cron.service Failed to start cron.service: Unit cron.service not found. $ sudo systemctl start cron Failed to start cron.service: Unit cron.service not found. 

My attempts to use cronie instead of cron:

$ sudo dnf install cronie Package cronie-1.5.7-3.fc35.x86_64 is already installed. Dependencies resolved. Nothing to do. $ sudo systemctl enable cronie.service Failed to enable unit: Unit file cronie.service does not exist. $ sudo systemctl start cronie.service Failed to start cronie.service: Unit cronie.service not found. 

Note also that anacron ("cronie.service") remains, if previously installed, during a Fedora system upgrade, but is NOT installed on, at least, Fedora Server 35, very surprisingly, when doing a fresh installation.

3
  • 1
    On my F35 XFCE VM, the crond service is installed and enabled by default; process is /usr/sbin/crond -n. Commented Dec 30, 2021 at 2:20
  • @ajgringo619 That worked! How did you find the location of crond? Commented Dec 30, 2021 at 3:13
  • 1
    For future reference, the service is named crond.service. Docs: docs.fedoraproject.org/en-US/fedora/f35/… Commented Dec 30, 2021 at 3:28

4 Answers 4

4

If this command is used:

# systemctl start crond.service 

then the system will keep it up for you, even through reboots. Thus, you don't have to remember to do it!

Further, to get status, use:

# systemctl status crond.service 

Finally, # of course means from the root account, so use sudo (or not) as appropriate.

0

Cron executed my backup script after using the crond location posted by ajgringo619:

$ ls -l /usr/sbin/crond -rwxr-xr-x. 1 root root 74448 Jul 21 15:05 /usr/sbin/crond $ sudo /usr/sbin/crond start $ pgrep cron 121692 
0

Your script is probably using/calling resources with relative path and or shell environment context.

Cron runs its scripts without shell and without environment context.

Try running your script with user nobody :

 sudo -u nobody <your-scirpt-full-path> 

Once your script is running with user nobody it may run in cron.

A common trick to inject current bash shell environment context to a script:

 sed -i "2i source $HOME/.bash_script" <your-scirpt-full-path> 
0

On Ubuntu please use the following command

sudo service cron start 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.