6

I want to execute a script on every start up, wake up and activation. In the current setup the script is executed in:

/etc/rc.local

/lib/systemd/system-sleep

It works so far, but if I reactivate my PC after 12 hours when it is in suspend to disk mode, the script won't be executed. If I wake my PC after 1 hour when it is in suspend to RAM mode it will be executed.

Do you guys know a path or way to execute a script on every turn on? Thank you.

  • Maybe this will help? http://askubuntu.com/questions/308067/how-to-run-a-script-after-or-before-hibernate –  Jun 10 '16 at 15:20
  • Thank you, but this works only for versions < 15.04. Discussed here => http://askubuntu.com/questions/226278/run-script-on-wakeup – YvanEhtNioj Jun 10 '16 at 15:34
  • Ahh, makes sense, I should have picked up on your systemd path. Knowing it's newer, but still what Ubuntu are you using? –  Jun 10 '16 at 15:45
  • Ah, sorry I didn't mention it. Ubuntu 16.04 LTS... An other option could be a path or way how to run a script everytime on login. – YvanEhtNioj Jun 10 '16 at 16:29

1 Answers1

0

It works as described in my question. But if your script needs a network connection, you have to wait several seconds before executing the script.

  • after further testing i found it there are 2 options that are used when calling scripts in that directory: "pre" and "post" (pre-suspend and post-suspend). so i just added condition to my script that if it's "post" then do my commands ... works OK now, thanks – mauek unak May 28 '17 at 05:22