2

This command work manually in WSL Ubuntu but not in cron. Manually it is:

touch /var/www/html/myFile.sh

By cron every minute it is:

* * * * * touch /var/www/html/myFile.sh

Why it's not effective when in cron?

4
  • 1
    I don't think WSL starts the cron service by default - have you done so manually? Jan 15, 2018 at 14:05
  • Oh, you were right. It doesn't. When I've got it started with service cron start it did and the file was creatred successfully. Thanks! Jan 15, 2018 at 14:16
  • @steeldriver answer please :-)
    – Rinzwind
    Jan 15, 2018 at 14:55
  • @Rinzwind - done Jan 15, 2018 at 15:14

1 Answer 1

2

WSL does not provide a complete Ubuntu environment by default - in particular, it may not start all the conventional system services. At least at the time of writing this answer, cron seems to be one of those, as discussed in this /r/bashonubuntuonwindows/ thread

Crontab Not Working with Bash on Ubuntu on Windows

The suggested solution is to start the service manually: on WSL that is done1 by

service cron start

1 despite being based on Ubuntu 16.04, WSL does not appear to use systemd

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .