啟用Windows 10/11 內置 WSL2的Crontab服務
logo source: PNGWing
前言: |
Linux
的Crontab
排程,無論是備份還是執行任務都非常方便。但
Windows
內置的WSL2
(Windows Subsystem for Linux)Crontab
服務,預設是沒有啟用,所有的排程也不會被執行,只能每次進入到WSL2
內手動啟用Crontab
服務。
操作步驟: |
進入到WSL內,設置帳號sudo
免密碼。
這樣是為了給Windows
呼叫Crontab
服務時不用輸入密碼。
sudo tee /etc/sudoers.d/user <<< 'user ALL=(ALL) NOPASSWD: ALL'
在Windows 的執行
(run
),開啟自啟動目錄。
SHELL:STARTUP
右鍵
-> 新增(W)
-> 捷徑(S)
對應圖示,目標(T)
及開始位置(S)
貼上以下內容。
%WINDIR%\System32\wsl.exe sudo /etc/init.d/cron start
%%WINDIR%\System32
最後進入到WSL2
,新增排程指命。
crontab -e
0 0 * * 7 /home/user/archiveHW.sh
@reboot /home/user/mount.sh
0 4 * * * /mnt/nas04/Tools/user/Bak_Rsync.sh
結語: |
這樣就可以在Windows的系統內自動執行Linux的排程及腳本。
Hey there, You've done a great job. I'll definitely digg
it and personally suggest to my friends. I'm sure they'll be benefited from this website.
casino en ligne
I think everything posted made a lot of sense.
However, what about this? suppose you composed a catchier title?
I am not saying your information isn't good., but suppose you added a headline that
makes people want more? I mean 啟用Windows 10/11 內置 WSL2的Crontab服務 - King Zone is a little boring.
You might look at Yahoo's front page and watch how they create post headlines to get people to click.
You might try adding a video or a related picture or two to grab readers interested about what you've written. In my opinion,
it might bring your posts a little livelier.
website
Hi there mates, how is all, and what you want to say about this piece of writing, in my view its truly amazing designed for me.
website
We are a gaggle of volunteers and starting a brand new scheme
in our community. Your site provided us with valuable information to work on. You have done a
formidable process and our whole neighborhood will probably be thankful to
you.
website
This design is spectacular! You obviously know how to keep
a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost...HaHa!) Wonderful job.
I really enjoyed what you had to say, and more than that, how you
presented it. Too cool!
casino en ligne fiable
Hi there, every time i used to check website posts here in the early
hours in the dawn, as i love to gain knowledge of more and more.
web site
Good day! Do you know if they make any plugins to protect against hackers?
I'm kinda paranoid about losing everything I've worked hard on. Any recommendations?
casino en ligne francais
Pretty element of content. I just stumbled upon your web site and in accession capital to say that I get actually loved account your weblog posts.
Anyway I'll be subscribing in your augment and even I fulfillment
you get admission to constantly rapidly.
site
May I simply say what a relief to find somebody that genuinely understands what they are talking about online.
You actually realize how to bring an issue to light
and make it important. A lot more people ought to read this and understand this side
of your story. I was surprised that you aren't more popular given that you surely have the
gift.
web site
Informative article, just what I wanted to find.
casino en ligne
Avec Inventonslemondedapres, identifiez facilement les casinos en ligne proposant les
meilleures conditions de jeu !