0
0

More than 5 years have passed since last update.

エディタを開かずに crontab にジョブを登録する

Last updated at Posted at 2013-12-24

crontab -e で編集した内容は /var/spool/cron/ユーザ名に保存されるのでそのファイルに直接書いてしまえばよい

$ echo '*/10 22 * * * ls' | sudo tee /var/spool/cron/sonots
$ crontab -l
*/10 22 * * * ls

これで xargs と組み合わせて複数ホストに一気に設定できる

$ echo -e "host1\nhost2" | xargs -I{} ssh {} 'echo '\''*/10 22 * * * ls'\'' | sudo tee /var/spool/cron/sonots'
$ echo -e "host1\nhost2" | xargs -I{} ssh {} crontab -l # 確認

尚、

'\''

は ' のエスケープである

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0