I have a small script that checks if my
rsync backup has completed and if so sleeps my machine.
This is on WSL (Debian).
#!/bin/bash # if rsync is running, then wait 5 while ps aux | grep -q -e "[r]s"; do sleep 5 echo "script running..." done # sleep PC psshutdown64.exe -d -t 0
This works fine when launching from a WSL window.
If the script is running, it waits, and when I terminate
rsync, the machine sleeps.
script running... script running... script running... script running... PsShutdown v2.53 - Shutdown, logoff and power manage local and remote systems Copyright (C) 1999-2021 Mark Russinovich Sysinternals - www.sysinternals.com
I'm trying to create a Windows shortcut to launch the same script.
When launching the shortcut, the loop never exits.
It keeps showing
script running... without sleeping.
powershell.exe to launch the script.
Interestingly, when I launch the script through a cmd or Powershell window, then it works fine:
wsl sh sleep.sh PsShutdown v2.53 - Shutdown, logoff and power manage local and remote systems Copyright (C) 1999-2021 Mark Russinovich Sysinternals - www.sysinternals.com
But it fails if I use a shortcut to launch it.
EDIT: the script is saved in a folder within
Documents. But the script is indeed executable and works fine in WSL.