Recently I started using win10 and WSL.

I want to let crontab run the following command.

/usr/sbin/shutdown now

But it's not working even the command works in Linux OS (I checked it already).

The reason why I want to do it is; I want to forcefully let the computer be off during the night since the adjacent persons told me to be quiet (noise of CPU fan?) through the night.

What can I do for next?

What exactly I want to do is as the below.

  1. As the computer is activated during 22:00~05:59, the shutdown command will be executed and let user fails to log in.
  2. As the computer is activated without the stated time zone, the computer leads me to log in and do the kind of shutdown at 2200

If really WSL can't do so, how can I achieve the thing using task scheduler or something?

  • If you gracefully shut down the Windows 10 host, WSL will shut down as well.
    – John
    Jul 7, 2021 at 12:50
  • I am confused by this question. Just shutdown Windows. This isn't how you shutdown WSL by the way. You can simply use wsl.exe --shutdown instead. If you want help troubleshooting the command that doesn't work you have to provide us more information. You can do that by performing an edit and giving us just a tad bit more information.
    – Ramhound
    Jul 7, 2021 at 13:32
  • WSL does not convert your PC into a Linux system, therefore please use the standard Windows ways for executing a scheduling a command, like Windows task scheduler.
    – Robert
    Jul 7, 2021 at 13:34
  • 2
    Does this answer your question? How to make WSL run services at startup Jul 7, 2021 at 16:11
  • Why downvote? Because it's dumb or what? This is a valid, if misinformed question. It is exactly what Super User is here for.
    – Daniel B
    Jul 7, 2021 at 20:28

1 Answer 1


Unfortunately, there are a number of assumptions you are making in your question that just won't work. I'll cover each of those below. While this information is covered in other questions and answers here on Super User, it can be difficult to "put together" all of the information. So while one might consider this a "duplicate" of those questions (as I originally did), it probably does need its own answer to aggregate all of the other related answers.

So, let's tackle this piece-by-piece:

  1. You are trying to get cron to work under WSL

    The problem here is that WSL isn't designed to "start up" services at boot, since there is no concept of a WSL "boot". Please see this question for more information on that aspect.

  2. You are trying to shutdown WSL via a Linux shutdown command

    WSL is a virtualized environment without direct control over the hardware. The Linux /usr/sbin/shutdown command in WSL does not have access to the host hardware. The proper way to shutdown WSL itself is by running wsl --shutdown (from PowerShell, CMD, or the Start Menu). This is covered in this question, although since it predates the wsl, you have to look at the second answer.

  3. You are trying to shutdown Windows via a Linux shutdown command

    As mentioned in the comments, the WSL lifecycle is different from that of Windows. WSL is software that runs in Windows. Shutting down the WSL environment is (to some extent) like exiting Notepad with File->Exit or Alt+F4. You wouldn't expect Windows to shutdown when you shutdown Notepad, nor should you expect Windows to shutdown when you shutdown WSL.

    To shutdown Windows, see the shutdown.exe command, covered in numerous other Super User questions.

Your real question is at the bottom -- How to do this with Task Scheduler. This question covers using shutdown.exe in Task Scheduler, for starters. That can, at least, run the shutdown at 22:00.

Then it sounds like you also want to have something that checks if a user is trying to log in between the "quiet hours" and prevent it. That's covered in this answer with the Windows net user /time command. Also see the other answers here for more along the lines of what you are trying to do.

Finally, you want to shut down Windows if it has been started up during the quiet times. This should also be done via a shutdown.exe in a Task Scheduler task that repeats every so often. Tasks like this are covered in multiple answers here on Super User, but here's one for reference.

  • Downvoter, can you explain what's wrong with this answer in your opinion and how it should be improved?
    – gronostaj
    Jul 7, 2021 at 20:26
  • It's okay - Some folks don't like "answers" on a duplicate, especially when I point out in the answer that it's a duplicate. Then again, if it requires assembling knowledge from 5 other questions/answers, perhaps it has evolved to be a valid question in its own right. I could see either side. Jul 7, 2021 at 22:47
  • I agree that it's a valid question in it's own right so I'm awarding both this answer as the question itself. I personally feel that SO can be a bit elitist where people that already know the answer use this information (that OP doesn't have) to tell OP that his question is not ok. I learned in school that there are no bad/dumb questions. No one likes dupes, but the fact that Google brought me to this answer and not to the so called dupers is telling. Apparently Google likes this answer more, for some reason. Sep 4, 2021 at 12:59
  • I see a contradiction in @NotTheDr01ds' answer. On the one hand, they start off brusquely, needlessly critiquing OP's question as "so many assumptions" ending with "I am going to recommend closing this as duplicate". A go away message. So disheartening! Then they proceeds to give an excellent answer, going through all the options, making this a stellar answer for people to find. Why? Why not just answer OP's question without the shaming? Oct 11, 2021 at 19:22
  • @JerryAsher There's no "shame" implied in a duplicate. If I feel the user could have found it on their own, I usually add a comment asking the user to read our "How do I ask a good question" page, and point out the "Search, and Research" advice. That's my "polite" version of "shaming", which I think follows our "be nice" policy. I answered this question because, as I mentioned in an earlier comment, it would be difficult to assemble the info from 5 different questions/answers. Definitely no shame in that, but it could still be seen as a duplicate (or duplicates), or perhaps not. Oct 11, 2021 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.