0

My server has not been running cron jobs since March 25, though it was running before that day and nothing has changed.
The OS version is Ubuntu 8.04LTS.

First, I restarted cron and checked processes.

$ sudo /etc/init.d/cron restart
 * Restarting periodic command scheduler crond
   ...done

$ ps aux | grep cron
root     14893  0.0  0.0  19640   908 ?        Ss   14:50   0:00 /usr/sbin/cron
user     16144  0.0  0.0   4972   844 pts/0    R+   14:50   0:00 grep cron

$ pgrep cron
14893

It seems that the cron process is running but when I checked status:

$ /etc/init.d/cron status
 * Usage: /etc/init.d/cron {start|stop|restart|reload|force-reload}

I guess there's something wrong.

I checked syslog

$ less /var/log/syslog | grep CRON

Mar 25 07:50:01 mail /USR/SBIN/CRON[12406]: (user) CMD (/home/user/public_html/rails_app/current/script/runner -e production "NewsRelease.send_unnoticed_mails" >> /home/user/public_html/rails_app/current/log/cron.log 2>&1)
Mar 25 07:50:01 mail /USR/SBIN/CRON[12409]: (user) CMD (/home/user/public_html/rails_app/current/script/runner -e production "Link.send_unnoticed_mails" >> /home/user/public_html/rails_app/current/log/cron.log 2>&1)
Apr  7 11:47:19 mail /usr/sbin/cron[13954]: (CRON) INFO (pidfile fd = 3)
Apr  7 11:47:19 mail /usr/sbin/cron[13955]: (CRON) STARTUP (fork ok)
Apr  7 11:47:19 mail /usr/sbin/cron[13955]: (CRON) INFO (Skipping @reboot jobs -- not system startup)

The logs after Apr 7 are logs when I run commands for cron manually.
Therefore cron has not been running since Mar 25.

My crontab file is below. It is to execute rails and ruby methods. These jobs were running successfully before March 25.

# Begin Whenever generated tasks for: rails_app

PATH=/usr/loca/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
50 7 * * * /home/user/public_html/rails_app/current/script/runner -e production "Link.send_unnoticed_mails" >> /home/user/public_html/rails_app/current/log/cron.log 2>&1

0 5 * * * /home/user/mysql_backup.sh >> /home/user/public_html/rails_app/current/log/cron.log 2>&1

0,15,30,45 * * * * /home/user/public_html/rails_app/current/script/runner -e production "Tweet.post_tweet_at" >> /home/user/public_html/rails_app/current/log/cron.log 2>&1

# End Whenever generated tasks for: rails_app
Zanna
  • 70,465
  • 1
    Um, 12.04 reaches end-of-life April 28, 2017. Ubuntu 8.04 was buried long ago. You might want to consider upgrading to a current release. – b_laoshi Apr 07 '17 at 06:31
  • I know well about it and I'm working on building a server, but I have to solve this problem for my service on my current server. – DIGITALSQUAD Apr 07 '17 at 06:51
  • If you just need it as a stop-gap until you get the new server up and running, why not write a script that runs in an infinite loop with pauses if you want that can call your cron command when you need it to? Then tell this script to run at boot (obviously not using cron). – b_laoshi Apr 07 '17 at 07:09

1 Answers1

3

If I read the comments correctly, you're looking for a temporary fix while you get a new server running a supported OS up and running. In that case, you might try the following

Create a script that will run an infinite loop to make your calls instead of trying to fix cron on a very obsolete OS. Something like this should do.

#!/bin/bash

while true
do
    time=$(date +%H:%M)
    hr=$(cut -f1 -d: <<< "$time")
    min=$(cut -f2 -d: <<< "$time")

    if [ "$hr" == "07"] && [ "$min" == "50" ]; then
        #run something at 7:50am
    fi

    if [ "$hr" == "05" ] && [ "$min" == "00" ]; then
        #run something at 5am
    fi

    if [ "$((min % 15))" == "0" ]; then
        #run something every quarter hour
    fi

    sleep 60
done

Then of course there is the task of running this at boot time. My 8.04 days are long past, and I can't say what worked back then. Take a look at this post though, and see if it gets you where you want to be.

b_laoshi
  • 4,660
  • 4
  • 25
  • 46
  • This solution will enough for me since it is for a temporary. I'll check the post and try this way. I appreciate your help. – DIGITALSQUAD Apr 07 '17 at 11:05