문제

일부 cygwin 명령은 있습니다 .exe 파일, 따라서 표준 Windows 스케줄러로 실행할 수 있지만 다른 사람들은 .exe 확장은 DOS에서 실행할 수 없습니다 (처럼 보입니다).

예를 들어 나는 원한다 updatedb 밤에 달리기.

Cron을 어떻게 만들 수 있습니까?

도움이 되었습니까?

해결책

설치해야합니다 cygrunsrv 따라서 Cron을 Windows 서비스로 설정 한 다음 실행할 수 있습니다. cron-config.

CRON 작업이 출력의 이메일을 보내려면 설치해야합니다. exim 또는 ssmtp (실행하기 전에 cron-config.)

보다 /usr/share/doc/Cygwin/cron-*.README 자세한 사항은.

없는 프로그램에 대해 .exe 확장, 아마도 어떤 유형의 쉘 스크립트 일 것입니다. 파일의 첫 번째 줄을 보면 파일을 실행하는 데 사용해야 할 프로그램을 볼 수 있습니다 (예 : "#!/bin/sh"), 따라서 쉘 프로그램 (예 :,”라고 호출하여 Windows 스케줄러에서 실행할 수 있습니다."C:\cygwin\bin\sh.exe -l /my/cygwin/path/to/prog".)

다른 팁

두 가지 옵션이 있습니다.

  1. cygrunsrv를 사용하여 Cron을 Windows 서비스로 설치하십시오.

    cygrunsrv -I cron -p /usr/sbin/cron -a -n
    
    net start cron
    

    (매우) 오래된 버전의 Cron에서 -n 대신 -d를 사용해야합니다.

  2. '비 .exe'파일은 아마도 Bash 스크립트이므로 스크립트를 실행하기 위해 Bash를 호출하여 Windows 스케줄러를 통해 실행할 수 있습니다.

    C:\cygwin\bin\bash.exe -l -c "./full-path/to/script.sh"
    

모자 팁 http://linux.subogero.com/894/cron-on-cygwin/

cygwin-setup을 시작하고 "admin"범주에서 "Cron"패키지를 추가하십시오.

우리는 사용자 시스템별로 CRON을 서비스로 실행합니다. 따라서 불쌍한 시스템에는 홈 디렉토리와 쉘이 필요합니다. “/etc/passwd”파일이이를 정의합니다.

$ mkdir /root
$ chown SYSTEM:root /root
$ mcedit /etc/passwd
SYSTEM:*:......:/root:/bin/bash

서비스 시작 :

$ cron-config
Do you want to remove or reinstall it (yes/no) yes
Do you want to install the cron daemon as a service? (yes/no) yes
Enter the value of CYGWIN for the daemon: [ ] ntsec
Do you want the cron daemon to run as yourself? (yes/no) no
Do you want to start the cron daemon as a service now? (yes/no) yes

로컬 사용자 이제 예정된 작업을 이와 같이 정의 할 수 있습니다 (Crontab은 좋아하는 편집자를 시작합니다).

$ crontab -e  # edit your user specific cron-table HOME=/home/foo
PATH=/usr/local/bin:/usr/bin:/bin:$PATH
# testing - one per line
* * * * *   touch ~/cron
@reboot     ~/foo.sh
45 11 * * * ~/lunch_message_to_mates.sh

도메인 사용자: 작동하지 않습니다. 가난한 CRON은 컴퓨터의 도메인 사용자를 대신하여 예약 된 작업을 실행할 수 없습니다. 그러나 또 다른 방법이 있습니다 : Cron은 또한 "/etc/crontab"의 시스템 레벨 CRON 테이블에서 발견 된 물건을 실행합니다. 따라서 시스템을 대신하여 시스템을 수행하도록 SUFF를 삽입하십시오.

$ touch /etc/crontab
$ chown SYSTEM /etc/crontab
$ mcedit /etc/crontab
HOME=/root
PATH=/usr/local/bin:/usr/bin:/bin:$PATH
* * * * *   SYSTEM touch ~/cron
@reboot     SYSTEM rm -f /tmp/.ssh*

마지막으로 Crontab 항목에 대한 몇 마디. 환경 설정 또는 예정된 명령입니다. 위에서 볼 수 있듯이 Cygwin에서 사용 가능한 경로를 만드는 것이 가장 좋습니다. 홈 디르와 껍질은 일반적으로“/etc/passwd”에서 가져옵니다.

예정된 명령의 열에 대해서는 매뉴얼 페이지를 참조하십시오.

특정 Crontab 항목이 실행되지 않으면 최상의 진단 도구는 다음과 같습니다.

$ cronevents

Cron의 옵션이 바뀌 었다고 덧붙이고 싶었습니다. -D보다는 -n을 통과해야합니다.

cygrunsrv -I cron -p /usr/sbin/cron -a -n

지침을 적용했습니다 이 답변 그리고 그것은 대답과 같은 더 많은 복사 페이스트를 지적하기 위해 노력했습니다 (Cygwin 설치 절차는 일종의 코피-페이스트 와이즈가 구현되어 있기 때문에)
Winlogo 버튼을 클릭하고 CMD.exe를 입력하고 마우스 오른쪽 버튼을 클릭하고 "관리자로 시작"을 선택하십시오. ~ 안에 CMD 즉각적인:

 cd <directory_where_i_forgot_the setup-x86_64.exe> cygwin installer:
 set package_name=cygrunsrv cron
 setup-x86_64.exe -n -q -s http://cygwin.mirror.constant.com -P %package_name%

설치 프로그램이 프롬프트에 오류를 던지지 않도록하십시오 ...있는 경우 - 아마도 Cygwin Binaries가 실행 중이거나 Windows Admin이 아니거나 약간의 버그가 없을 것입니다 ...

지금에 CMD 약속 :

 C:\cygwin64\bin\cygrunsrv.exe -I cron -p /usr/sbin/cron -a -D   

또는 cygrunsrv.exe에 필요한 전체 파일 경로를하고 CMD 프롬프트에서 Windows 서비스로 Cron을 시작할 수 있습니다.

 net start cron

지금에 세게 때리다 터미널 런 크론타 브 -e

Cron Entry를 설정하십시오. 예제 벨로우즈 :

        #sync my gdrive each 10th minute
    */10 * * * * /home/Yordan/sync_gdrive.sh

    # * * * * * command to be executed
    # - - - - -
    # | | | | |
    # | | | | +- - - - day of week (0 - 6) (Sunday=0)
    # | | | +- - - - - month (1 - 12)
    # | | +- - - - - - day of month (1 - 31)
    # | +- - - - - - - hour (0 - 23)
    # +--------------- minute

Windows 7에 로그온했을 때 Cygwin Cron 서비스를 자동으로 실행하는 방법을 알아 냈습니다. 다음은 다음과 같습니다.

메모장을 사용하여 파일을 만듭니다 C:\cygwin\bin\Cygwin_launch_crontab_service_input.txt 내용으로 no 첫 번째 줄과 yes 두 번째 줄에서 (인용문없이). 이것들은 프롬프트에 대한 두 가지 응답입니다 cron-config.

파일을 만듭니다 C:\cygwin\Cygwin_launch_crontab_service.bat 컨텐츠 :

@echo off
C:
chdir C:\cygwin\bin
bash  cron-config < Cygwin_launch_crontab_service_input.txt

Windows 시작 폴더에서 다음에 바로 가기를 추가하십시오.Cygwin_launch_crontab_service.bat

보다 http://www.sevenforums.com/tutorials/1401-startup-programs-change.html 스타트 업에 추가하는 방법에 대한 도움이 필요한 경우. BTW, 원하는 경우 선택적으로 시작에 추가 할 수 있습니다.

Cygwin

XWIN 서버

첫 번째는 실행됩니다

C:\cygwin\Cygwin.bat

그리고 두 번째는 실행됩니다

C:\cygwin\bin\run.exe /usr/bin/bash.exe -l -c /usr/bin/startxwin.exe

올바른 구문 설치 크론 Cygwin에서 Windows 서비스가 통과해야합니다 -N 논쟁으로서 -디:

cygrunsrv -Install cron -path/usr/sbin/cron -args -N

-디 시작시 사용량 오류를 반환합니다 크론 Cygwin에서 :

$

$ cygrunsrv- 인스턴 Cron --path/usr/sbin/cron -Args -D

$ cygrunsrv- 시작 Cron

cygrunsrv : 서비스 시작 오류 : queryservicestatus : win32 오류 1062 :

서비스가 시작되지 않았습니다.

$ cat /var/log/cron.log

Cron : 알 수없는 옵션 -d

사용법 :/usr/sbin/cron [-n] [-x [ext, sch, proc, parc, load, misc, test, bit]]]

$

아래 페이지에는 좋은 설명이 있습니다.

Windows에서 Cygwin Cron 서비스 설치 및 구성 :https://www.davidjnice.com/cygwin_cron_service.html

추신 나는 달려야했다 cygwin64 터미널 설치하려면 내 Windows 10 PC에서 관리자로서 크론 Windows 서비스로.

Getting updatedb to work in cron on Cygwin -- debugging steps
1) Make sure cron is installed.
 a) Type 'cron' tab tab and look for completion help.
   You should see crontab.exe, cron-config, etc.  If not install cron using setup.
2) Run cron-config.  Be sure to read all the ways to diagnose cron.
3) Run crontab -e
 a) Create a test entry of something simple, e.g.,
   "* * * * * echo $HOME >> /tmp/mycron.log" and save it.
4) cat /tmp/mycron.log.  Does it show cron environment variable HOME
   every minute?
5) Is HOME correct?  By default mine was /home/myusername; not what I wanted.
   So, I added the entry
   "HOME='/cygdrive/c/documents and settings/myusername'" to crontab.
6) Once assured the test entry works I moved on to 'updatedb' by
   adding an entry in crontab.
7) Since updatedb is a script, errors of sed and find showed up in
   my cron.log file.  In the error line, the absolute path of sed referenced
   an old version of sed.exe and not the one in /usr/bin.  I tried changing my
   cron PATH environment variable but because it was so long crontab
   considered the (otherwise valid) change to be an error.  I tried an
   explicit much-shorter PATH command, including what I thought were the essential
   WINDOWS paths but my cron.log file was empty.  Eventually I left PATH alone and
   replaced the old sed.exe in the other path with sed.exe from /usr/bin.
   After that updatedb ran to completion.  To reduce the number of
   permission error lines I eventually ended up with this:
   "# Run updatedb at 2:10am once per day skipping Sat and Sun'
   "10 2  *  *  1-5  /usr/bin/updatedb --localpaths='/cygdrive/c' --prunepaths='/cygdrive/c/WINDOWS'"

Notes: I ran cron-config several times throughout this process
       to restart the cygwin cron daemon.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top