2015-12-10 5 views
0

Я использую версию cygwin 2.3.1 (0.291/5/3) в Win7 и несколько часов пытаюсь запустить свою запланированную работу crontab. В моих глазах, что может быть проблемой, заключается в том, что мой процесс cron и мой процесс crontab имеют разных владельцев, и я не уверен, как это исправить.crontab не выполняется, отличается ли пользователь от cron и crontab?

Я создал задачу crontab, которая должна создать файл c: \ crontest.txt в первую минуту и ​​обновить каждую минуту после этого. Этого не происходит!

Вот мой вывод консоли при попытке получить этот кронтаб бегущего

[email protected] ~ $ cygrunsrv --install cron --path /usr/sbin/cron --args -n 

[email protected] ~ $ cygrunsrv --start cron 

[email protected] ~ $ ps -al 
     PID PPID PGID  WINPID TTY   UID STIME COMMAND 
    10856 11196 11196  1360 pty0  197608 14:51:33 /usr/bin/rsync 
    2120  1 2120  2120 ?    18 Dec 8 /usr/bin/cygrunsrv 
    8256 8304 8256  8808 pty0  197608 02:00:54 /usr/bin/bash 
S 6848 2940 2940  684 pty1  197608 19:58:41 /usr/bin/vi 
S 4408  1 10840  11008 pty1  197608 20:00:54 /usr/bin/vi 
    11196 8256 11196  8188 pty0  197608 14:51:31 /usr/bin/bash 
    12240  1 12240  12240 ?   197608 19:58:05 /usr/bin/mintty 
    7284 12240 7284  6396 pty1  197608 19:58:06 /usr/bin/bash 
S 2940 7284 2940  6360 pty1  197608 19:58:41 /usr/bin/crontab 
    6764 10856 11196  4696 pty0  197608 14:51:33 /usr/bin/ssh 
     216  1  216  216 ?   197608 19:58:07 /usr/bin/ssh-agent 
    11420 11196 11196  236 pty0  197608 14:51:33 /usr/bin/tee 
    8512  1 8512  8512 ?   197608 02:00:55 /usr/bin/ssh-agent 
     636  1  636  636 ?    18 22:14:14 /usr/bin/cygrunsrv 
    11292  636 11292  8092 ?    18 22:14:15 /usr/sbin/cron 
    13048 7284 13048  13044 pty1  197608 22:14:25 /usr/bin/ps 
    8304  1 8304  8304 ?   197608 02:00:54 /usr/bin/mintty 

[email protected] ~ $ ps -ef | grep cron | grep -v grep 
    User 2940 7284 pty1  19:58:41 /usr/bin/crontab 
    SYSTEM 11292  636 ?  22:14:15 /usr/sbin/cron 

[email protected] ~ $ crontab -l 
# DO NOT EDIT THIS FILE - edit the master and reinstall. 
# (/tmp/crontab.dl91rLtszY installed on Wed Dec 9 22:07:56 2015) 
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $) 
* * * * * echo "Cron test at $(date +\%k:\%M)" >> /cygdrive/c/crontest.txt 2>&1 

[email protected] ~ $ 

хрон сервис с PPID 636, как показано выше, также показана в службах Windows 7, как PID 636 и Win7 видит это как бег.

Может ли кто-нибудь увидеть, что я могу делать неправильно, или какую другую информацию я могу вам предоставить, чтобы помочь мне получить эту работу?

ответ

0

Да.

Ну, после долгих копаний и прыжков веры я узнал, как сделать cron работать как тот же пользователь, что и crontab.

Как только они использовали одного и того же пользователя, мой crontab начал работать!

В основном мне приходилось запускать cron-config и правильно отвечать на вопросы. Есть момент, когда мне нужно было ввести мой пароль пользователя Win7 для моей учетной записи «Пользователь». Из чтения я сделал, похоже, что это потенциальная проблема безопасности, но я единственный администратор в одной домашней сети, поэтому я решил, что все в порядке.

Вот последовательность команд, которая заставила меня идти:

[email protected] ~ $ cron-config 
The cron daemon can run as a service or as a job. The latter is not recommended. 
Cron is already installed as a service under account LocalSystem. 
Do you want to remove or reinstall it? (yes/no) yes 
OK. The cron service was removed. 

Do you want to install the cron daemon as a service? (yes/no) yes 
Enter the value of CYGWIN for the daemon: [ ] ntsec 

You must decide under what account the cron daemon will run. 
If you are the only user on this machine, the daemon can run as yourself. 
    This gives access to all network drives but only allows you as user. 
To run multiple users, cron must change user context without knowing 
    the passwords. There are three methods to do that, as explained in 
    http://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-nopasswd1 
If all the cron users have executed "passwd -R" (see man passwd), 
    which provides access to network drives, or if you are using the 
    cyglsa package, then cron should run under the local system account. 
Otherwise you need to have or to create a privileged account. 
    This script will help you do so. 
Do you want the cron daemon to run as yourself? (yes/no) no 

Were the passwords of all cron users saved with "passwd -R", or 
are you using the cyglsa package ? (yes/no) no 

Finding or creating a privileged user. 
The following accounts were found: 'cyg_server' . 
This script plans to use account cyg_server. 
Do you want to use another privileged account name? (yes/no) yes 
Enter the other name: User 

Reenter: User 


Account User already exists. Checking its privileges. 
INFO: User is a valid privileged account. 
INFO: The cygwin user name for account User is User. 

Please enter the password for user 'User': 
Reenter: 
Running cron_diagnose ... 
... no problem found. 

Do you want to start the cron daemon as a service now? (yes/no) yes 
OK. The cron daemon is now running. 

In case of problem, examine the log file for cron, 
/var/log/cron.log, and the Windows event log (using /usr/bin/cronevents) 
for information about the problem cron is having. 

Examine also any cron.log file in the HOME directory 
(or the file specified in MAILTO) and cron related files in /tmp. 

If you cannot fix the problem, then report it to [email protected] 
Please run the script /usr/bin/cronbug and ATTACH its output 
(the file cronbug.txt) to your e-mail. 

WARNING: PATH may be set differently under cron than in interactive shells. 
     Names such as "find" and "date" may refer to Windows programs. 


[email protected] ~ $ ps -ef | grep cron | grep -v grep 
    User 2944 11780 ?  03:31:10 /usr/sbin/cron 
    User 2940 7284 pty1  19:58:41 /usr/bin/crontab 

[email protected] ~ $ 
Смежные вопросы