Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

Reset Accelerator

Switch to Root User, then type:

reboot

Example crontab using delay script

#
# Delay the startup of my daemon processes. The start_after_delay
# script is a Ruby script which will Kernel.sleep the given time
# (plus a random 10% extra) before executing the given command
#
@reboot /home/mmower/bin/start_after_delay 45m /usr/local/bin/ruby /home/mmower/domains/metavalues.com/apps
/instiki-0.10.2 --port nnnn --storage /home/mmower/domains/metavalues.com/apps/instiki-0.10.2/storage
@reboot /home/mmower/bin/start_after_delay 45m /usr/local/sbin/lighttpd -f /home/mmower/lighttpd/lighttpd.c
onf

Ruby script to delay execution of a command (intended for @reboot crontab)

#!/usr/local/bin/ruby
# Start after delay
#

# Delay specifications must be one of Xs (secs), Xm (mins), Xh (hours)
case ARGV[0]
when /(\d+)s/
@delay = $1.to_i
when /(\d+)m/
@delay = 60 * $1.to_i
when /(\d+)h/
@delay = 3600 * $1.to_i
else
raise "Incorrect delay specification"
end

# A random factor of up to 10% will be added to any given delay
@rf = ( @delay * 0.1 ).to_i
@delay += rand( @rf )
sleep( @delay )

# Join up remaining arguments to form the command to be executed
ARGV.slice!( 0 )
@command = ARGV.join( ' ' )
exec( @command )
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed