×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    69

    Run script on shut down

    Hi all

    Is it possible somehow to run a script/program on shutdown?
    Like the startup script is starting the daemons, I would like to run a small script before the device shuts down.

    I could write a daemon which checks for my signal all the time, but this seems to be very wasting of resources, since this only will happen very seldom.

    To give some more details:
    I need to change a parameter in a config file. since this is only possible as root, the only way I know to do it, is by a script started by the system itself, i.e. as a daemon.
    The problem is: the change of the config file is only taken by the system after a reboot. So I would like to change the parameter and do a restart. If I only can change the parameter in a daemon, I would have to reboot twice (once to change parameter, then for the system to take the changed parameter).


    In the daemon documentation at http://harmattan-dev.nokia.com/docs/...g_daemons.html it sais this:
    Code:
    # If you need to do preparations, you can use normal Upstart stanzas
    # such as pre-start, post-start, script, pre-stop and post-stop sections
    # Start myapp as root
    exec /opt/myapp/bin/myapp
    Would pre-stop do what I need?
    How would I have to use it?

  2. #2
    Registered User
    Join Date
    Jul 2011
    Posts
    12

    Re: Run script on shut down

    pre-stop might work as a hack. It can be used for example like this:

    pre-stop exec /opt/myapp/bin/mysmallhackscript.sh
    exec /opt/myapp/bin/myapp

    Of course it's a hacky way to do it, and I haven't tried if it even works in harmattan. There's side-effects, like the script can be run even in cases when there is no shutdown if the daemon is stopped by other means (for example if user uninstalls the application and you are automatically stopping the daemon).

    Here's some more ideas, but some of these don't work with harmattan's restricted UpStart environment:
    http://askubuntu.com/questions/30383...-shutdown-hook

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: Run script on shut down

    pre-stop script
    ...
    end script

    post-stop script
    ...
    end script

    the above scripts in the /etc/init/<yourapp> shall be executed when the process is killed (started at upstart)
    please have a look at /etc/init/csd.conf in device ternimal(n9), it uses all the options of pre-start, post-start, pre-stop and post-stop.

Similar Threads

  1. how to automatic shut down the phone
    By julio_chan in forum Symbian Media (Closed)
    Replies: 4
    Last Post: 2011-03-29, 12:53
  2. N97 won't shut off
    By markboost in forum Symbian
    Replies: 2
    Last Post: 2010-01-06, 09:32
  3. HttpConnection causes MIDlet to shut down..
    By mortenlindeberg in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2008-03-25, 09:21
  4. Shut down using EHotKey
    By liafail in forum Symbian
    Replies: 0
    Last Post: 2005-12-20, 05:49
  5. Can't shut down GPRS connection..
    By betyouaint in forum Symbian
    Replies: 0
    Last Post: 2004-08-30, 11:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×