Make Cygwin have cron

Source: Internet
Author: User

If you want to perform auto-scaling on Windows XP/2003 sever. Early in Windows NT 3.51/4.0, If You Want To allow Windows to perform some manual operations, you should first use the DOS shell command to upload one. bat or. then run the at command to specify the time when the row is to be executed. In this way, when the time is reached, you will be able to perform the operations that you want to perform manually. I used this kind of machine when I was working in the middle school. However, the DOS shell is too powerful, so it can only be realized if it has actually been done. Therefore, Microsoft has a set of scripts for base on VBscript, which makes such a job a little bit more efficient. However, I think this kind of things will only be heard by people who have passed the WeChat Certification Examination [1, if you want to write this program fluently, there won't be too many people, because someone who wants to find a teaching material will give you some advice. It seems that the best source of information is Microsoft Technet, oh... you still have to eat something from WeChat. Even if you don't think it is delicious, you can't eat it.

Unix users have more than just shell, and you have a lot of options to use. You can use the Bourn Shell (sh) and C Shell (csh) of the ashes ), you can also select Korn shell (ksh), Z Shell (zsh), tcsh, bash (Bourn Again Shell )..., even Perl, PHP... these versions of shell are available for selection. In terms of teaching materials, the most common examples on the market are bash/sh, but there are also many examples of csh/tcsh, you can find out a bunch of books in this field, and there are a bunch of teaching documents on the Internet. There are a lot of Chinese teaching materials, no need for money.

As far as automation is concerned, at command has long been available on Unix, and the Windows version is still from the port on Unix. There is also a set of better systems-cron, which is also a necessary tool for network administrators. The largest feature of cron is simple, easy to learn, and easy to learn. It takes about one night to learn about cron.

When Windows 2000/XP/2003 was reached, Microsoft finally developed another method to transform the system functions into: You are a fool, it is a clear realm, to useConsole → scheduled jobsImplement GUI regionalization. However, the best choice is to use the DOS shell or VBscript shell of the operating system to compile the program, which is easier to control than the hacker. If I am already familiar with shell script scripting in Unix and want Cygwin to work with it, there is still a way to go [2]. More importantly, it is the most untrusted GUI interface of the system administrator. Therefore, if you are familiar with Unix, you often think about Cygwin, can Cygwin also have cron rows? The answer is yes, and it is not enough.

First, let's talk about how to implement security. First confirm whether you have already been concerned about cron. There are three methods to confirm:

The first one is the most stupid, most direct, and implements the setup.exe line directly.

The second method is Cygwin

$ Ls/usr/sbin/cron

If:

Ls:/usr/sbin/cron: No such file or directory

So there is no security, otherwise the cron case will appear.

The third method is in Cygwin

$ Ls/etc/setup | grep cron

If nothing is left blank, no response will be made; otherwise, cron.lst.gz will appear. The third method is the most formal, because/etc/setup stores some of the kit information of the security software, all your installed kits can find their .lst.gz labels here.

This article requires the cron and cygrunsrv suites. If you have taken the test beforeInstalling sshd on WindowsSo cygrunsrv should have been used. For the cron suite's security process, please take the test firstAdded images on Cygwin-Example of installing joe and rxvtIn Cygwin, the methods for installing new software are the same. When the Select Packages statement of the following statement is displayed, press the + marker before the Admin statement to open the statement. Select "Security cron" as the following statement, also, confirm whether the cygrunsrv under it is to be upgraded. If yes, please start it at the moment, however, this action does not need to be manually triggered. The setup program will automatically add it.

Since cron itself is a Unix daemon, it needs to be written immediately when the machine is turned on. InInstalling sshd on WindowsIn this article, I once mentioned that cygrunsrv is required. With this tool, your program [3] can be automatically triggered during Windows activation in the form of Windows service [4], just like the daemon on Unix. If you want to know how to use cygrunsrv, run the following command in Cygwin:

$ Cygrunsrv -- help

Therefore, we must first repeat sygrunsrv. The recommended maximum number of rows is:

$ Cygrunsrv -- install cron -- desc 'cygwin cron daemon' -- path/usr/sbin/cron.exe -- args-D

You can goConsole> system management tools> Service, OpenServiceThe Caller confirms whether there areCronThis service appears, and then check whether it has beenOperation, Also confirmDynamic typeIs it true?Automatic. If you wantDynamic typeUseMobileType, then add the dynamic number of rows-- Type manualHere. I want to explain the meaning of the number of arguments in the preceding command.-- InstallWhat isServiceThe real name of the domain name. You will need to manually renew the domain name in the future.ServiceThis is the name directly.-- DescInServiceCaller pendingDescriptionThis column shows the content, so it is optional. Note that if there are blank characters in the text, remember to enclose them in simple quotes.-- PathIs a program command that really needs to be executed. Please note that the program path must be complete and cannot be used for further test.$ PATH.-- ArgsIt is the number of bytes that the command itself will carry. In this case, we need to use it because we want to make cron a dead row in the background.Cron-DTherefore-DPut the data in the -- args computing environment. I want to renew it again.-- DispThis parameter refersServiceCaller pendingNamespaceThis column shows the content. However, it only indicates the name of the token, notServiceThe real name.Net start...,Net stop...These are relatedServiceInstead of using this name-- InstallThe real name specified later. However, if you do not likeServiceCaller pendingNamespaceThis column only shows the dull cron, so you can use-- DispThis parameter, for example-- Disp 'cygwin cron', InServiceCaller pendingNamespaceIf this column is output, it will become Cygwin cron. Is it clear?

If you want to remove the cron service, you can merge it:

$ Cygrunsrv -- remove cron

This is not necessary.

Only when you are inServiceThe caller should see that the current cron response should be blank, that is, stopped. To activate cron, you can directlyServiceIn the target, click cron and pressMobile ServerIt is a black triangle to the right, just like playing audio on a CD player or audio player. You can also run one of the following commands in Cygwin to activate the cron service:

$ Cygrunsrv -- start cronOr

$ Net start cron

Stop it as follows:

$ Cygrunsrv -- stop cronOr

$ Net stop cron

BeforeInstalling sshd on WindowsIn this article, we should have seen the same method used to initiate sshd. To confirm whether it has been successfully completed, you can click the following line in Cygwin:

$ Ps-ef | grep cron

SYSTEM 4068 3724? 18:53:55/usr/sbin/cron

Or

$ Ps-a | grep cron

4068 3724 4068 3920? 18 18:53:55/usr/sbin/cron

If this happens, the transaction starts. To confirm whether the job is correct, you can add a job first:

$ Crontab-e

* ***/Usr/bin/date>/tmp/hahaha

The preceding condition indicates that each row is cron rows.DateCommand to indicate the time at that time, and then add the time to the end of/tmp/hahaha. You can use cat/tmp/hahaha after the Shard to check whether the Shard is normal.

$ Cat/tmp/hahaha

Fri Apr 14 20:19:00 2006

Fri Apr 14 20:20:00 2006

Fri Apr 14 20:21:00 2006

Fri Apr 14 20:22:00 2006

If you are not familiar with cron, take a look at Newbie: Intro to cron. This article is a very good teaching document.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.