Apart from video games one of the great advantages of using computers is that they don’t seem to mind doing boring and repetitive tasks that we would rather not do.以外のコンピュータを使用しての大きな利点の1つのビデオゲームというよりは、我々は、そんなことはしない退屈な反復的な作業を行う気にしていないようです。 For monotonous tasks such as running daily backups we are better off scheduling them to run at a certain time every day, and do more interesting stuff with our time.このような我々のスケジュール設定をオフにする特定の時間に、毎日毎日のバックアップを実行するように優れている単調な作業を実行しても、私たちの時代とはもっと面白いものです。 Linux and UNIX usually come with the utility “crontab” by default. LinuxおよびUNIXは通常、ユーティリティ"のcrontabで"デフォルトで来る。 This very useful command allows you to schedule tasks to run at a specified time and repeat as configured.これは非常に便利なコマンドは、指定された時間と設定の繰り返しで実行するタスクをスケジュールすることができます。 A task scheduled using “crontab” is called a “cron job”.タスク" " 、 " cronジョブと呼ばれています"のcrontabを使用する予定。
The crontab command allows you to instruct your server to execute a script at a specified minute of the specified day of the particular month. crontabのコマンドは、指定された場合は、特定の月の1日の分で、指定されたスクリプトを実行するには、サーバーに指示することができます。 To see what cron jobs are setup to run on your machine, run the following command:お使いのマシン上で実行するcronジョブのセットアップには、以下のコマンドを実行して何かを参照するには:
# crontab -l # のcrontab - lを
If your machine has some cron jobs configured it will display something like the following:あなたのマシンでいくつかのcronジョブをしているが、以下のようなものが表示される設定:
0 6 * * * /opt/scripts/backup_script.sh 0 6 * * *が/ opt /スクリプト/ backup_script.sh
The crontab configuration above shows a cron job that executes the shell script “backup_script” everyday at 6 AM.上記のcrontabの設定は午前6時では、シェルスクリプト" backup_script "日常を実行するcronジョブが表示されます。 The * means to run at every instance of the value in the field. *は、フィールドの値のすべてのインスタンスで実行することを意味します。 So an asterisk in the day, month, and day of week fields in the above example means that the script should run every day of the month, every month of the year, and every day of the week.上記例では1日、 1週間のフィールドにアスタリスク月、日、月のようにスクリプトを毎日実行する必要がありますことを意味、今年の毎月、毎日。 The first and second fields tell crontab to execute the script at zero minutes and six hours, which is 6 AM.最初と2番目のフィールドは午前6時はゼロ分、 6時間では、スクリプトを実行するためにcrontabを報告してください。 So, this cron job configuration would read something like this, “Run the script /opt/scripts/backup_script.sh at zero minutes, 6 AM, every day, every month, and every day of the week.” Below is the “anatomy” of a crontab configuration explained.そのためには、このcronジョブ構成は、 "スクリプトを実行し、 /ゼロ分、午前6時、 1週間毎日、毎月、毎日/スクリプト/ backup_script.sh選ぶこのような何かを読む"と述べた。以下は、 "解剖学です" crontabの設定の説明している。
0 6 * * * /opt/scripts/backup_script.sh 0 6 * * *が/ opt /スクリプト/ backup_script.sh
| | | | | | | | | |
| | | | |________________ day of week (Sunday=0) |今週の| | | |________________日(日曜日= 0 )
| | | |__________________ month of year | | | |__________________年の月
| | |____________________ day of month |今月| |____________________日
| |______________________ hour of day | |______________________ 1日の時間
|________________________ minute of hour |________________________時間分
To schedule new cron jobs or to edit old ones execute the following command:または新規のcronジョブをスケジュールするには古いものを編集するには、次のコマンドを実行:
# crontab -e # crontabをメールする
This will bring up an editor with which you can add, edit, or delete “cron jobs”.この"を追加、編集、または" cronジョブを削除するエディタをもたらすでしょう。 To schedule a job to run at 3:45 PM every Monday add entry like this:月曜日3:45 PMに実行するようにこのようなエントリを追加全ての仕事をスケジュールするには:
45 15 * * 1 /opt/scripts/script.sh 45 15 * * 1が/ opt /スクリプト/ script.sh
You can also use a comma to add multiple entries into a field.また、フィールドに複数のエントリを追加するには、カンマを使用できます。 This is useful if you want to run a script thrice a day, with an eight hour interval. 1日1回の場合はスクリプトを実行するのに、これは、 8時間の間隔で便利です。 Make sure you do not leave space between entries in a single field, though.必ずエントリの間に1つのフィールドにはスペースを空けていないことを確認します。 Your “cron job” entry would look like this:あなたの" cronジョブ"エントリは次のようになる:
0 1,9,17 * 2,11 * /opt/scripts/db_backup_script.sh 0 1,9,17 * 2,11 *が/ opt /スクリプト/ db_backup_script.sh
In the above example the script “db_backup_script.sh” runs at 1 AM, 9 AM, and 5 PM every day in the months of February and November.このスクリプト" db_backup_script.sh "午前1時、午前9時、毎日午後5時で2月と11月のか月で実行上記の例では。 There are a lot of cool things that you can do with cron jobs.あなたのcronジョブを行うことができますクールなことがたくさんある。 The same works for day, month, and day of week. 1日、同じ作品月、曜日。 Once you get the hang of this try out the following.一度は、以下の場合は、これを試してみるのがハングする。 Crontab doesn’t only understand numbers, it can also operate on some basic English words: crontabの数字のみを理解していない場合、またいくつかの基本的な英語の単語で動作することができます:
string explanation文字列の説明
—— ———– -- ---
@reboot Run once, the next time the system reboots @再起動を実行後、次の時間は、システムが再起動
@yearly Run once a year, at the beginning of the year @年間を実行して、 1年に1回、今年の初めに
@annually Same as @yearly, run once annually @ @毎年毎年、同じ1回、毎年実行
@monthly Run once a month, at the beginning of the month @毎月の実行は毎月1回、その月の初めに
@weekly Run once a week, at the beginning of the week @週1回実行して、週に1回、週の初めに
@daily Run once a day, at midnight深夜@毎日実行して、 1日1回、
@midnight Same as @daily, run at midnight毎日深夜@ @として、真夜中に実行同じ
@hourly Run once an hour, at the beginning of the hour @ 1時間ごとに実行して1時間に1回、 1時間の冒頭に
So, for example, if you want to run a script at midnight every night, this is what your crontab configuration would look like:そのためには、たとえば、毎晩午前零時にスクリプトを実行することが、ここはあなたのようになります。 crontabを設定します:
@midnight /opt/scripts/script.sh @真夜中が/ opt /スクリプト/ script.sh
Using “@midnight” rather than “0 0 * * *” will work the same and execute the requested script at midnight every night while being a lot more readable than its numerical counterpart. "真夜中の@ "ではなく"より0 0 * * * "を使用して、同じ仕事をし、真夜中に毎晩、要求スクリプトを実行中に多くの国の数値よりも読めるしている。 You can also make the use of hyphens to declare a range.また、ハイフンの使用範囲を宣言することができます。 In the command below “script.sh” will be executed at the beginning of every hour from 1 AM to 6 AM: " script.sh "以下のコマンドでは午前1時から1時間ごとの冒頭に午前6時に実行されます:
0 1-6 * * * /opt/scripts/script.sh 0 1-6 * * *が/ opt /スクリプト/ script.sh
There are many more cool things you can do with cron.あなたのcronで行うことができます多くのクールなものがあります。 Every sysasmin swears by it, it’s pretty easy to use once you get the hang on it, and very powerful.一度に慣れる毎週sysasminで断言は、かなり使用するように、非常に強力な簡単だ。 Use this tool wisely, as scheduling a task wrongly can sometimes do a lot of harm.賢く、間違っても害は多くのタスクのスケジュール設定を行うことができるとして、このツールを使用してください。 Reading the “man page” of crontab would be highly recommended.のcrontabの" manページ"レディング強く推奨される。






















{ 0 comments… ( 0コメント... add one now今すぐ追加 } )
Leave a Commentコメントを残しなさい