Koozali.org: home of the SME Server

How to use @reboot for crontab with delay

Offline Bud

  • *
  • 487
  • +0/-0
How to use @reboot for crontab with delay
« on: April 16, 2015, 01:26:46 PM »
good day guys hope you can help me

using sme 8.1 server

i am trying to run 2 cronjob's using the sme 8.1 Crontab Manager Contrib " http://wiki.contribs.org/Crontab_Manager "

i have configured it as such

on the user administrator option the two cronjob's are

command to be executed = @reboot /bin/sleep 180 ; /etc/rc7.d/./S97job start
command to be executed = @reboot /bin/sleep 280 ; /etc/rc7.d/./S99rdc start

i am trying to get these two cronjob's to start after a server reboot at the mentioned time delay

i have not entered any other options

needless to say the conjobs do not work

please help the noob to resolve the cronjob's to start after a server reboot  :-D


Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: How to use @reboot for crontab with delay
« Reply #1 on: April 16, 2015, 01:41:54 PM »
what about taking a look into /var/log/ directory? :-)

messages and crond files

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: How to use @reboot for crontab with delay
« Reply #2 on: April 16, 2015, 03:30:20 PM »
on the user administrator option the two cronjob's are

command to be executed = @reboot /bin/sleep 180 ; /etc/rc7.d/./S97job start
command to be executed = @reboot /bin/sleep 280 ; /etc/rc7.d/./S99rdc start

i am trying to get these two cronjob's to start after a server reboot at the mentioned time delay

The first thing I notice is you have used a very unusual path to your scripts. Why do you have '/./' rather than just '/'?

Second thing is that '/etc/rc7.d/S97job start' will already have been run during system startup. Ditto for S99rdc. Why are you using both /etc/rc7d/ startup ("SysVinit scripts"), as well as a cronjob?

Third you are introducing race conditions. It seems that you are intending to run S99rdc after S97job. Do you intend for S97job to end before you start S99rdc? Because if so, you are not doing anything to ensure that that is true.

Fourthly, there are various bug reports about @reboot jobs in cron, e.g.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=635473

I don't know whether any of those apply to CentOS/SME server, but it's something to consider.

In summary, there are probably better ways to solve your problem, whatever that is. We don't know what you are trying to do, but this is an unusual way to try to do it.


Offline Bud

  • *
  • 487
  • +0/-0
Re: How to use @reboot for crontab with delay
« Reply #3 on: April 18, 2015, 05:52:03 AM »
stefano and CharlieBrady thank you for trying to help

yes it does look strange i understand, let me try explain

the client has a specialized application that is used in a production environment and whenever the sme 8.1 server reboots the two services " S97job  " and " S99rdc " do not start.

i have to manually start them after a server reboot by doing the following:

# cd /etc/rc7.d
# ./S97job start
# ./S99rdc start

after doing the above everything works.

how do i get this done every time the sme 8.1 server reboots?

the client has huge production issues and when i am driving and not in front of a computer when the server reboots due to a power failure the client get's upset when his systems are down hence no production.

any help greatly appreciated  :smile:

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: How to use @reboot for crontab with delay
« Reply #4 on: April 18, 2015, 08:07:02 AM »
Bud

see
http://wiki.contribs.org/SME_Server:Documentation:Developers_Manual
ie the section titled
Starting up programs automatically upon system boot
(almost at the end)


For a lazy Linux way, but not so standard for sme server, see an example in the Wondershaper Howto
http://wiki.contribs.org/Wondershaper

If you search these forums you will find plenty of practical examples that have been posted over the years.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: How to use @reboot for crontab with delay
« Reply #5 on: April 18, 2015, 04:17:18 PM »
the client has a specialized application that is used in a production environment and whenever the sme 8.1 server reboots the two services " S97job  " and " S99rdc " do not start.

The obvious question to ask is why they don't start. Solve that problem and you won't need to do battle with cron.