Ask Your Question
0

How can i make cron work on Fedora 25?!

asked 2017-04-20 16:43:35 -0500

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

Comments

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

genodeftest gravatar imagegenodeftest ( 2017-04-20 17:04:02 -0500 )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 gravatar imagegenodeftest ( 2017-04-20 17:06:43 -0500 )edit

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

ed209 gravatar imageed209 ( 2017-04-20 20:04:12 -0500 )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 gravatar imageDavid-LDA ( 2017-04-22 08:55:49 -0500 )edit

4 Answers

Sort by » oldest newest most voted
0

answered 2017-04-21 22:20:34 -0500

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

Comments

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 gravatar imageDavid-LDA ( 2017-04-22 08:58:37 -0500 )edit
0

answered 2017-04-22 15:23:54 -0500

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
0

answered 2017-04-22 15:22:59 -0500

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

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-04-20 16:43:35 -0500

Seen: 2,185 times

Last updated: Apr 22 '17