[Samba] Shutting down a remote PC via "net rpc"

Stefan G. Weichinger lists at xunil.at
Mon Dec 14 18:17:36 UTC 2020

customer runs a Windows 2019 DC in Subnet, Domain "ourdom"


Samba 4.9.5-Debian as domain member, in same subnet. Works fine.


The kid's PC is domain member in a separate VLAN "kids" ;-)

The wish: a cron job should shut down that kids PC every 5 minutes 
between X and Y o'clock.

The following bash script failed with "could not initialise pipe 

while the same command *worked* when executed in the shell.

I now enforced the "Remote Registry" service on the kids PC.

when I run it via bash script:

"Shutdown of remote machine failed"

5 seconds later as shell command:

"Shutdown of remote machine succeeded"

Any ideas, why? Why not?

login shell vs. non-login shell?
env variables?

I am also happy if anyone points me to something more modern or elegant:

define it in a GPO on the DC  ... or anything like that.

-> script:

# cat pc_shutdown_schedule.sh


net rpc shutdown -C "PC-Zeit ist von Montag bis Freitag von 16.00 Uhr 
bis 18.30 Uhr. Am Wochenende von 9.00-11.00 und von 17.00 bis 18.30 Uhr. 
PC f�hrt in wenigen Sekunden herunter." -t 60 -f -I -U 
'administrator%Something67//' -W ourdom

thanks, regards, Stefan

More information about the samba mailing list