Ask Your Question

How can i make cron work on Fedora 25?!

asked 2017-04-20 21:43:35 +0000

David-LDA gravatar image

I would like to run a script everyday at a certain time to do something. I am used david, who has admin rights.

I can edit my task with crontab -e

21 21 * * * /home/david/scripts/night.sh

I can see it with crontab -l

It does not work!

If i type systemctl status crond:

● crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-04-20 17:23:29 BST; 4h 17min ago
 Main PID: 1095 (crond)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/crond.service
           └─1095 /usr/sbin/crond -n

Apr 20 17:23:29 sumomo systemd[1]: Started Command Scheduler.
Apr 20 17:23:29 sumomo crond[1095]: (CRON) INFO (Syslog will be used instead of sendmail.)
Apr 20 17:23:29 sumomo crond[1095]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 67% if used.)
Apr 20 17:23:29 sumomo crond[1095]: (CRON) INFO (running with inotify support)
Apr 20 18:01:01 sumomo CROND[4044]: (root) CMD (run-parts /etc/cron.hourly)
Apr 20 19:01:01 sumomo CROND[4603]: (root) CMD (run-parts /etc/cron.hourly)
Apr 20 19:01:01 sumomo run-parts[4612]: (/etc/cron.hourly) finished 0anacron
Apr 20 21:01:02 sumomo CROND[6879]: (root) CMD (run-parts /etc/cron.hourly)
Apr 20 21:21:01 sumomo crond[1095]: (david) RELOAD (/var/spool/cron/david)
Apr 20 21:22:01 sumomo crond[1095]: (david) RELOAD (/var/spool/cron/david)

So it's doing a RELOAD at the right time (don't know what that means), but not actually running my script.

I can't find any cron.deny files, can't see any SELINUX warnings, and I definately can't even find the mysterious vixie-cron mentioned here https://docs.fedoraproject.org/en-US/Fedora/12/html/Deployment_Guide/ch-autotasks.html

Please help :)

edit retag flag offensive close merge delete


Maybe you will have to restart cron (or at least give it some signal) so it catches up your changes?

genodeftest ( 2017-04-20 22:04:02 +0000 )edit

You might want to use a systemd timer unit, if you want to run a command from crontab. See man systemd.timer for details.

genodeftest ( 2017-04-20 22:06:43 +0000 )edit

What is written inside /var/log/chrony ? Anything strange for your user inside /var/spool/cron/ ?

ed209 ( 2017-04-21 01:04:12 +0000 )edit

Hi guys. I have tried restarting the cron service, there is nothing inside /var/log/chrony and /var/spool/cron/ does not exist. I don't really want to get involved in man systemd.timer as I would like to just get the cron working properly, I hope to use cron on my web hosting server too and want to master it without adding any extra complexity.

David-LDA ( 2017-04-22 13:55:49 +0000 )edit

4 answers

Sort by » oldest newest most voted

answered 2017-04-22 20:23:54 +0000

lahcen gravatar image

1 sudo chmod 644 /home/david/scripts/night.sh 2 open crontab with command: sudo crontab -e 3 add this line @reboot /home/david/scripts/night.sh 4 restart to preview sudo reboot

edit flag offensive delete link more

answered 2017-04-22 20:22:59 +0000

lahcen gravatar image

1 sudo chmod 644 /home/david/scripts/night.sh 2 open crontab with command: sudo crontab -e 3 add this line @reboot /home/david/scripts/night.sh 4 restart to preview sudo reboot

edit flag offensive delete link more

answered 2017-04-22 03:20:34 +0000

Cron may not execute your night.sh script if it does not think it is an executable file.

Use the 'file' command to see what type of file is detected:

file /home/david/scripts/night.sh

Should return something like:

/home/david/scripts/night.sh: Bourne-Again shell script, ASCII text executable

If the returned string does not include the word ' executable', make sure the first line in night.sh contains:

#!/bin/bash or #!/bin/sh

This tells the system the file is a bash or shell script.

edit flag offensive delete link more


The file night.sh is definitely executable, I have tested that. I have also tested having the script start echo 'hello' in case my absolute file paths in the script are not working for some strange reason. Nothing happens :(

David-LDA ( 2017-04-22 13:58:37 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question Tools



Asked: 2017-04-20 21:43:35 +0000

Seen: 1,927 times

Last updated: Apr 22 '17