2

I have ubuntu system and I want to check the condition before the system goes off means system get shutdown. If condition is satisfied then allow to shutdown the system

otherwise halt the shutdown event. If any command is there on ubuntu then please tell me.

So please advice me

1 Answer 1

1

There is no easy way to do that but you can make this trick.

  1. create a script that test your condition and run it whenever shutdown is run.
  2. If the condition is ok then shutdown
  3. If the condition fails kill shutdown command.

Details:

To execute a script at shutdown:

Put your script in /etc/rc6.d directory

Make it executable:

sudo chmod +x K99_script

Now this script will just execute when you try to shutdown.

Inside the script, if condition fail then run one of thesw commands:

pkill shutdown

OR

killall shutdown
1
  • I tried it but it is not work for me. System get shutdown after I click on shutdown button. If there is any other solutions then please tell me. Mar 5, 2014 at 11:57

You must log in to answer this question.

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