■ solaris10 cron 設定 2010/03/05 更新
設定手順
  1. 現在の状態確認。 スーパーユーザで登録されているスケジュールがいくつか見えますね。
    # svcs |grep cron
    online   1月_18  svc:/system/cron:default

    # crontab -l root
    緑:デフォルト、オレンジ:変更箇所
     
    #ident "@(#)root 1.21 04/03/23 SMI"
    #
    # The root crontab should be used to perform accounting data collection.
    #
    #
    10 3 * * * /usr/sbin/logadm
    15 3 * * 0 /usr/lib/fs/nfs/nfsfind
    30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
    #10 3 * * * /usr/lib/krb5/kprop_script ___slave_kdcs___
     
  2. 定期的に実行したいシェルを準備する。
     
  3. crontab コマンドを実行するための環境設定
    # EDITOR=vi
    # export EDITOR
     
  4. スケジュールの登録を行う。
    # crontab -e root
    緑:デフォルト、オレンジ:変更箇所
     
    #ident "@(#)root 1.21 04/03/23 SMI"
    #
    # The root crontab should be used to perform accounting data collection.
    #
    10 3 * * * /usr/sbin/logadm
    15 3 * * 0 /usr/lib/fs/nfs/nfsfind
    30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
    #10 3 * * * /usr/lib/krb5/kprop_script ___slave_kdcs___
    10 4 * * * /root/scripts/file_remove.sh ※1
    ※1 毎日午前 4:10 に file_remove.sh を実行する。
      10  4  *  *  *   /root/scripts/file_remove.sh
      分 時 日 月 曜日 シェルやコマンドを記述する。    詳しくは man crontab で確認。
     
その他、crontab コマンドのアクセス制限
# vi /etc/cron.d/cron.allow ※1
緑:デフォルト、オレンジ:変更箇所
 
root
username1
username2
username3

# cat /etc/cron.d/cron.deny ※2
緑:デフォルト、オレンジ:変更箇所
 
daemon
bin
smtp
nuucp
listen
nobody
noaccess
※1 cron の使用を許可されているユーザーのリスト。 初期状態では存在しないファイル。
allow リストを作成すると、リスト以外のユーザは crontab のコマンド使用が制限される。
※2 cron の使用を禁止されているユーザーのリスト。