You are not logged in.
Pages: 1
Hi,
I have two seperate crons. One needs to run on startup and the other on shutdown. How can I do this? Also it would be useful to make it if the first one on startup fails (eg. due to no internet connection) the second on shutdown is skipped.
Thanks.
Offline
Hi,
I have two seperate crons. One needs to run on startup and the other on shutdown. How can I do this? Also it would be useful to make it if the first one on startup fails (eg. due to no internet connection) the second on shutdown is skipped.
Thanks.
What you probably need is a startup script rather than cron. cron executes commands chronologically and so it would be impossible to initiate something on boot and shutdown using cron.
For eg. if you use Openbox, you can add the commands that you need to run on startup in the ~/.config/openbox/autostart.sh file.
You can have a shutdown script as well, to see if "whatever you started" has executed or not and accordingly execute the shutdown script.
Last edited by Inxsible (2008-07-08 16:20:12)
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
How would I go about creating a startup script? Thanks.
Offline
How would I go about creating a startup script? Thanks.
What WM or DE do you use?
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
Gnome.
Offline
What exactly are you trying to do ?
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
What exactly are you trying to do ?
It's explained in my first post - running crons on startup and shutdown. They are rsync crons.
Offline
# /etc/rc.local: Local multi-user startup script.
# /etc/rc.local.shutdown: Local shutdown script.
Offline
# /etc/rc.local: Local multi-user startup script.
# /etc/rc.local.shutdown: Local shutdown script.
Thanks have to figure out how to skip the shutdown script if the startiup one isn't successful.
Offline
What exactly are you trying to do ?
HAHAHAHAH moljac...i like your sig....permission to quote it sometimes somewhere else?......... with due credits of course
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
xdeusx wrote:# /etc/rc.local: Local multi-user startup script.
# /etc/rc.local.shutdown: Local shutdown script.Thanks have to figure out how to skip the shutdown script if the startiup one isn't successful.
On successful startup script -- you could probably set a user-defined environment variable. Then before running the shutdown script - check for that variable and do things accordingly.
IMP NOTE: Make sure that the variable you select is unique and something that no other program developer might think of using, or you may mess up some other system variable or have problems with another program using the same environment variable.
Last edited by Inxsible (2008-07-08 18:35:37)
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
Thanks for the info however I have no idea how to either make these scripts or set the variables.
Offline
Thanks for the info however I have no idea how to either make these scripts or set the variables.
Create a sh file . for eg. startupscript.sh. Use your favorite editor to add the following lines to it
#!/bin/sh
//simply add the commands that you want to be executed on boot.
//After ALL the commands make sure you add
export YOURUNIQUEENVVAR=SUCCESS
Now create a shutdownscript.sh. Your shutdown script will first check for the variable you set....and if it is SUCCESS, only then will it execute its commands. Something like
#!/bin/sh
if[YOURUNIQUEENVVAR == SUCCESS] then
//add your shutdown commands that you need executed
fi
Give both those files executable permissions
chmod +x /path/to/startupscript
chmod +x /path/to/shutdownscript
Then add the startupscript in the sessions. I think it is System>>Preferences>>Sessions. I could be wrong, I havent used Gnome is quite some time.
You will have to modify your quit mechanism to first execute the shutdown script when you select shutdown. I dont quite rbr how to do that. Of course you can simply put it under rc.local.shutdown
NOTE : above is just a pseudo code version of what you may need. you will have to add the appropriate commands to both the files. in the shutdown script you may also have to add an else branch where you would simply continue with shutting down etc.
Last edited by Inxsible (2008-07-08 20:04:27)
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
Thanks very much - very helpful.
Does anyone know how to edit the quit mechanism?
Offline
moljac024 wrote:What exactly are you trying to do ?
HAHAHAHAH moljac...i like your sig....permission to quote it sometimes somewhere else?......... with due credits of course
Go ahead I didn't come up with that, I also picked it up somewhere.... think it was linuxquestions.org
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
Anyone?
Offline
Thanks very much - very helpful.
Does anyone know how to edit the quit mechanism?
what do you mean with "quit mechanism"?
oh i got it...
you can simply edit /etc/rc.local for startup and /etc/rc.local.shutdown for shutdown.
the last will be executed when the system really shuts down.
Last edited by DonVla (2008-07-19 22:27:39)
Offline
I have two seperate crons. One needs to run on startup...
As a side note for future forum searchers, on some cron daemons (Vixie Cron?) you can use the special 'time' "@reboot" to execute things when the system boots. Useful if you don't have access to the rc.local files on the host (eg, shared hosting). I use it on my shared web host to send me an e-mail when their server is restarted just for my own info...
@reboot mail -s "Web Host Restarted" my@emailaddress.com < /dev/null
Last edited by fukawi2 (2008-07-20 07:24:31)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Another option if this is an arch machine, is to make an rc.d script and add it to DAEMONS. It will be run with the start parameter at boot, and the stop parameter at shutdown. You can use the add_daemon and rm_daemon functions to keep track of whether it ran successfully or not.
[git] | [AURpkgs] | [arch-games]
Offline
Pages: 1