2

I had many cron jobs working perfectly before upgrade from Ubuntu 16.04 to 18.04. After the upgrade I can run all the defined jobs (using crontab -e) either in terminal or by clicking "Run Selected Task" in GUI "Configure Scheduled Tasks" but all these jobs are not being executed at scheduled (or any other) times... To say once again, I can perfectly without any problem execute all the defined jobs (call to R scripts) using terminal or mentioned GUI.

Output of cat /var/log/syslog | grep cron :

Jul 25 16:16:41 usernameVB crontab[10530]: (username) LIST (username)
Jul 25 16:16:50 usernameVB crontab[10535]: (username) LIST (username)
Jul 25 16:16:59 usernameVB crontab[10545]: (username) LIST (username)
Jul 25 16:17:01 usernameVB CRON[10549]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jul 25 16:17:08 usernameVB crontab[10553]: (username) LIST (username)
... (more of the LIST lines)

How to make cron jobs run at defined times?

EDIT: Added output of sudo systemctl status cron.service:

$sudo systemctl status cron.service
[sudo] password for username: 
● cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: ena
   Active: active (running) since Mon 2018-07-23 02:42:23 EDT; 2 days ago
     Docs: man:cron(8)
 Main PID: 734 (cron)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/cron.service
           └─734 /usr/sbin/cron -f

Jul 24 10:17:01 usernameVB CRON[30421]: pam_unix(cron:session): session opene
Jul 24 10:17:01 usernameVB CRON[30422]: (root) CMD (   cd / && run-parts --re
Jul 24 10:17:01 usernameVB CRON[30421]: pam_unix(cron:session): session close
Jul 25 02:17:01 usernameVB CRON[17013]: pam_unix(cron:session): session opene
Jul 25 02:17:01 usernameVB CRON[17013]: pam_unix(cron:session): session close
Jul 25 13:17:01 usernameVB CRON[3767]: pam_unix(cron:session): session opened
Jul 25 13:17:01 usernameVB CRON[3768]: (root) CMD (   cd / && run-parts --rep
Jul 25 13:17:01 usernameVB CRON[3767]: pam_unix(cron:session): session closed
Jul 25 16:17:01 usernameVB CRON[10548]: pam_unix(cron:session): session opene
Jul 25 16:17:01 usernameVB CRON[10548]: pam_unix(cron:session): session close
lines 1-19/19 (END)

EDIT 2: I created jobs using command $crontab -e which opens /tmp/crontab.Rnzw6Y/crontab. The contents looks like this (several of those jut calling R scripts at different times/days).

45 15 * * 1-5 /usr/bin/R --vanilla --quiet < /home/username/code/scripts/R_script_1.R 2>&1 | tee -a "/home/username/log/R_script_1.R - `date +\%Y-\%m-\%d\ \%H:\%M:\%S`.log.txt" # JOB_ID_26

Let me point out that running this in terminal works just fine:

/usr/bin/R --vanilla --quiet < /home/username/code/scripts/R_script_1.R 2>&1 | tee -a "/home/username/log/R_script_1.R - `date +\%Y-\%m-\%d\ \%H:\%M:\%S`.log.txt"

All this worked perfectly fine until upgrade from 16.04 to 18.04.

  • Please add the output of "sudo systemctl status cron.service" to your question, it might tell us something. – Bernard Wei Jul 25 '18 at 21:16
  • @BernardWei Added output of "sudo systemctl status cron.service" – Samo Jul 26 '18 at 6:50
  • Looks like it is running. Where do you put your cron job configuration? Normally under /etc/cron.hourly, /etc/cron.daily, etc. are place where you put the tasks that need to be run at those interval. If you want other scheduling, create a cron schedule where you can configure precise time and interval. If you need help in setting up that, I can put an answer to your question on exactly how that can be done. – Bernard Wei Jul 26 '18 at 18:00
  • @BernardWei I have added more info. – Samo Jul 26 '18 at 21:12
  • 1
    Do you see any lines with RELOAD in the cron related syslog? Did you try something like * * * * * /usr/bin/touch /tmp/testfile for a generic test? If not, what are the results of that? Also watch the syslog in a second terminal with journalctl -u cron -f during this generic test and let us know the outcome. – Thomas Jul 28 '18 at 12:26
1

First, I ran the command on Ubuntu.

crontab -e

In the second step I did this:

* * * * * cd /var/www/html && php artisan schedule:run >> /dev/null 2>&1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.