それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

CygwinでCronサーバーを動かす

CygwinをつかえばWindowsでも簡単にCronを使うことが出来ます。いままでどうしてやらなかったんだ。便利すぎて大活躍。なぜ避けてきたんだ。そう思うくらい後悔したのです。


とりあえずデフォルトで入ってるみたい

インストール不要。Cygwin入ってたら不要。

takuya@amdE350:~$ apt-cyg install cron
Working directory is /setup
Mirror is ftp://ftp.jaist.ac.jp/pub/cygwin/
Package cron is already installed, skipping
takuya@amdE350:~$ 

設定する:cron-config

とりあえずやってみよう。

takuya@amdE350:~$ cron-config

起動すると以下の質問が聞かれる。


・Cronはサービスとして実行するのか
・Cronはどのユーザーで動かすか?
・通常のユーザー(つまり自分)なのか、特権ユーザなのか
・特権ユーザーは既存の物を使うのか、新規作成するか


僕はSSH用に作った特権ユーザーを使い回したのでそれでいい。
再起動してみてもちゃんと動いているのが確認できる。

というわけで設定すれば、これで完了。

あとは通常と同じです。

takuya@amdE350:~$ crontab -e 

みんな大好きインストールログ。

takuya@amdE350:~$ cron-config                                                             ##インストールコマンド
Do you want to install the cron daemon as a service? (yes/no) yes              #サービスとして使うか? YES
Enter the value of CYGWIN for the daemon: [ ]

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                     #サービスは一般ユーザーTakuya で動かすか? No

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

Attempting to find or create a privileged user.
The following accounts were found: 'cyg_server' .
This script plans to use the name cyg_server for the new user,
which will only be able to run as a service.
Do you want to use another name (not an interactive account)? (yes/no) yes  # cygserver ユーザーあるけど、これつかう? yes

Please enter the password for user 'cyg_server':                                           # cygserver のパスワードちょうだい
Reenter:
Running cron_diagnose ...
WARNING: Your computer does not appear to have a cron table for takuya.
Please generate a cron table for takuya using 'crontab -e'                              # インストール終了。あとはcontab -e で

... no problem found.


ユーザーcygserverの追加を聞かれる。作っちゃうのが楽。SSHサーバーを入れてるときは、すでに作られているので、それを再利用する。