By William Jeffrey Rankin, Thu Dec 5 2024
Hua can be run at regular intervals using a scheduled task (on Windows) or a cron job (on Linux/Cygwin). On Windows, I use a simple batch script:
D:
cd Documents\Hua
D:\PowerShell-7.4.6-win-x64\pwsh .\hua.ps1 .\hua.cfg
Then I create a scheduled task. Two examples are shown below: the first runs daily, the second every hour.
schtasks /create /sc daily /st 23:50 /tn "Hua" /tr D:\Documents\Hua.bat
schtasks /create /sc hourly /st 08:05 /tn "Hua" /tr D:\Documents\Hua.bat
On Linux and Cygwin it's a little simpler since the batch script is not necessary. The equivalent cron jobs look like this:
50 23 * * * cd Hua; pwsh hua.ps1 hua.cfg
5 * * * * cd Hua; pwsh hua.ps1 hua.cfg
Note that in the case of Cygwin, you'll need to use the full path to pwsh:
50 23 * * * cd Hua; /cygdrive/c/PowerShell-7.4.6-win-x64/pwsh ./hua.ps1 ./hua.cfg
If you want to suppress Hua's output, direct it to /dev/null
as shown below. Output is still sent to Hua's log file.
50 23 * * * cd Hua; pwsh hua.ps1 hua.cfg > /dev/null