Enable cron to run without asking for password
Normally running sudo service cron start
in WSL will ask for the sudo password. This is an issue when we want to run cron from the script below. To fix this, we need to enable cron
service to run without asking for the password by adding it to /etc/sudoers
.
|
|
Create a file to start cron in a hidden window
Create a .vbs file (VBScript) with the following code.
(If you're copying the code, you can remove the comment in line 4 starting with `'`.)
|
|
Start WSL cron on Windows startup
To start cron when Windows starts up, copy the above .vbs file to the Windows startup folder. You can get to the startup folder by running shell:startup
in the Run window (Win+R).