Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have set up cron jobs which stop services at 2:00 AM and then restarts them at 8:00 AM. However, my enterprising users (my family; securing the box isn't a possibility) have determined that if they reboot the box, the services come back online as part of the default boot process.

The best solution I was able to come up with was to modify the start/stop scripts to examine the time as a condition, or to have the cron jobs place a flag file on disk that the services start jobs look for prior to allowing startup. (The second decouples the schedule so I'm only entering it in one place and allows me to easily override it.)

Is this the best technical way to approach the problem? Is there another way to link the shutdown via cron that I'm unfamiliar with?

share|improve this question
up vote 1 down vote accepted

OK, the service I wanted to control has been converted to Upstart. Per the Upstart Cookbook, temporarily disabling a service so that it doesn't start on the next boot is done via the following:

# echo "manual" >> /etc/init/myjob.override

So I created the following start up and shutdown script to be called from cron:



# Create the override file if it doesn't already exist.
if [ ! -f $OverrideFile ]
    echo Creating flag file $OverrideFile.
    echo "manual" >> $OverrideFile
    echo Flag file $OverrideFile exists.

# Stop the plexmediaserver service.
/sbin/stop plexmediaserver



# Remove the override file if exists.
if [ -f $OverrideFile ]
    rm $OverrideFile

# Start the plexmediaserver service.
/sbin/start plexmediaserver

I then modified the cron jobs to use the newly created batch files and it appears to be working.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .