On 2025-08-12 10:34, Roland Mainz via Cygwin wrote:
Is there any example for cygrunsrv to run a (cleanup) dash/bash script
when a Win32 service (set up via cygrunsrv) gets stopped ?

I am unaware of any possible Windows shutdown dependency options desktop users can access, and any service dependency would have to be an executable daemon runnable as a Windows service under cygrunsrv.

You may be able to set up a SYSTEM scheduled task on service state change event id 7036 if running on MS Windows servers, however it looks like this may have been dropped on MS Windows Desktops, with other unannounced quiet changes.

If you run Cygwin services including syslog-ng and cron, with service logging to syslog, you could intermittently check for service state changes from a cron command and execute a script, with suitable permissions to /var/log/syslog.

I find it useful to set up services with Delayed Start and Preshutdown, and run manual service start and stop scripts to control the situation, except on power fails! ;^>

Power Fail, Cygwin, and System update shutdown and restart syslog:

Aug 10 03:05:46 $HOSTNAME syslog-ng[1077]: syslog-ng starting up; 
version='3.2.5'
Aug 10 03:05:49 $HOSTNAME /usr/sbin/cron: PID 1089: (CRON) STARTUP (V5.0)
Aug 10 03:05:49 $HOSTNAME cron: PID 1088: `cron' service started
...
Aug 11 17:19:24 $HOSTNAME cron: PID 1088: `cron' service stopped, exit status: 0
Aug 11 17:19:27 $HOSTNAME syslog-ng[1077]: Termination requested via signal, terminating;
Aug 11 17:19:27 $HOSTNAME syslog-ng[1077]: syslog-ng shutting down; 
version='3.2.5'
Aug 11 17:33:12 $HOSTNAME syslog-ng[365]: syslog-ng starting up; version='3.2.5'
Aug 11 17:33:14 $HOSTNAME /usr/sbin/cron: PID 377: (CRON) STARTUP (V5.0)
Aug 11 17:33:15 $HOSTNAME cron: PID 376: `cron' service started
Aug 11 17:45:28 $HOSTNAME syslog-ng[365]: Termination requested via signal, terminating;
Aug 11 17:45:30 $HOSTNAME cron: PID 376: `cron' service stopped, exit status: 0
Aug 11 17:45:28 $HOSTNAME syslog-ng[365]: syslog-ng shutting down; 
version='3.2.5'
Aug 11 17:52:15 $HOSTNAME /usr/sbin/cron: PID 868: (CRON) STARTUP (V5.0)
Aug 11 17:52:15 $HOSTNAME cron: PID 867: `cron' service started
Aug 11 17:52:13 $HOSTNAME syslog-ng[858]: syslog-ng starting up; version='3.2.5'

--
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                -- Antoine de Saint-Exupéry

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to