Ubuntu 18.04 on WSL cron daemon not running after reboot

I have Ubuntu 18.04.1 LTS running under Windows 10 Pro. After every reboot, the cron daemon is not started.

I can start it manually with sudo service cron start.

What can I configure or what system file I need to modify so that after a reboot, the cron daemon starts?


As it is described in the article Starting Linux Background Services on Windows Login you need to trigger your command sudo service cron start from Windows. You can use Windows Task Scheduler for this purpose. Here are the steps from the mentioned article with a slight modifications:

1. Create startup script and make it executable:

echo "service cron start" | sudo tee /usr/local/bin/cronstart.sh
sudo chmod +x /usr/local/bin/cronstart.sh

Thus cronstart.sh will be accessible as shell command system wide.

2. Create a file within /etc/sudoers.d/ with purpose to allow your $USER to execute cronstart.sh by sudo without password. Run the following command to generate the line that must be placed in the sudoers file:

echo "$USER ALL=(ALL) NOPASSWD: /usr/local/bin/cronstart.sh"

Copy the output of the command, use the command sudo visudo -f /etc/sudoers.d/cronstart and paste the copied line as content of the newly created file. Save the file and exit.

3. Within Windows, go to the search bar, find and run Task Scheduler (as administrator if your current account isn't administrators one).

Now, click Task Scheduler Library on the left and then Create Task… on the right to create a new task. You can use the following parameters to configure the task:

  • General tab:

    Name the task anything you want, like WSL service cron start.

    Choice the option Run whether user is logged or not.

    Mark Do not store password and Run with highest privileges.

    In the Configure for dropdown select Windows 10.

    If you need to setup a task for another user click on the button Change User or Group....

  • Triggers tab:

    Click New… to add a new trigger for this task.

    In the Begin the task dropdown select At startup.

    Within the Advanced settings you can check Delay task for 1 minute.

  • Actions tab:

    Click New… to add a new action for this task.

    Pick Start a program for the action type and then enter C:\Windows\System32\wsl.exe as the program to run.

    At Add arguments (optional) set this: sudo cronstart.sh.

That’s it. Reboot the system, then open WLS terminal and use service cron status to check whether cron is running.


I've made some tests and unfortunately I found Windows 10 experiences some bugs and it is almost impossible to setup such task for a non-administrator user's account, while you are using Windows account instead of local one ... complete mess :O

As workaround in this case you can create a file called cronstart.bat in the folder shell:startup with content as follow:

C:\Windows\System32\wsl.exe sudo cronstart.sh

How to use VBS instead of a bat file to achieve the same result is shown here:

  • Windows Subsystem for Linux Autoload Apache2 and MySql