Temporarily Prevent Linux from Shutting Down

Prevent system sleep/shutdown/reboot in a bash script

On OS X, you can use the caffeinate -s /path/to/your/script command to prevent sleep while your script runs.

How to Prevent System from Shutting down or Restart in a Win32 service?

You can't.

Because allowing programs to prevent shutdown/restart would be somewhat of a security vulnerability, don't you think?

If the user tells the system to shutdown or restart, that's what's going to happen.

BTW, WM_QUERYENDSESSION is passed when the current user is logging out of Windows. It's a notification, nothing more, and if you're using it in any other way then you're using it wrongly.

How can I tell Puppet to stop a service on shutdown without keeping it running?

Puppet does not have any built-in support for configuring which runlevels a service runs in, nor any built-in, generalized support for chkconfig. Ordinarily it is a service-installation responsibility to register the service with chkconfig; services that are installed from the system RPMs are registered that way.

Furthermore, chkconfig recognizes structured comments at the top of initscripts to determine which runlevels the service will run in by default, according to LSB convention. A proper initscript need only be registered with chkconfig to have the default runlevels set -- in particular, for it to be set to be stopped in runlevels 0 and 6, which is what you're after.

If you're rolling your own initscripts and deploying them manually or directly via Puppet (as opposed to packaging them up and installing them via Yum) then your best bet is probably to build a defined type that manages the initscript and its registration. You do not need and probably do not want a Service resource for it, but a File resource to put the proper file in place and an Exec resource to handle registration sounds about right.



Related Topics



Leave a reply



Submit