Mastahe - Aku juga menanyakan hal yang sama pada hari ini, "Bagaimana sih cara masang Cronjob di Digital Ocean?". Jawabnya ternyata ada di https://www.digitalocean.com/community/articles/how-to-use-cron-to-automate-tasks-on-a-vps .
Cara menginstallnya sangat mudah,,
Masuk ke VPSmu, lalu :
Cara menginstallnya sangat mudah,,
Masuk ke VPSmu, lalu :
For Ubuntu/Debian:
sudo apt-get update
sudo apt-get install cron
For Cent OS/Red Hat Linux:
sudo yum update
sudo yum install vixie-cron crontabs
You’ll need to make sure it runs in the background too:
sudo /sbin/chkconfig crond on
sudo /sbin/service crond start
Lalu kalau masu memasukan perintah ke dalam cronjobnya, buka aja panel cronjobnya dengan mengetikkan:
crontab -e
Kalau mau buat view aja:
crontab -l
Misal mau menghapus silakan masukan perintah:
crontab -r
Nah, berikut data lengkap istilah cronjob yang semoga bisa memberi manfaat bagi anda.
Syntax
Here is an example task we want to have run:
5 * * * * curl http://www.google.com
The syntax for the different jobs we’re going to place in the crontab
might look intimidating. It’s actually a very succinct and
easy-to-parse if you know how to read it. Every command is broken down
into:
- Schedule
- Command
The command can be virtually any command you would normally run on
the command line. The schedule component of the syntax is broken down
into 5 different options for scheduling in the following order:
- minute
- hour
- day of the month
- month
- day of the week
Examples
Here is a list of examples for some common schedules you might encounter while configuring cron.
To run a command every minute:
* * * * *
To run a command every 12th minute on the hour:
12 * * * *
You can also use different options for each placeholder. To run a command every 15 minutes:
0,15,30,45 * * * *
To run a command every day at 4:00am, you’d use:
0 4 * * *
To run a command every Tuesday at 4:00am, you’d use:
0 4 * * 2
You can use division in your schedule. Instead of listing out 0,15,30,45, you could also use the following:
*/4 2-6 * * *
Notice the “
2-6
” range. This syntax will run the command between the hours of 2:00am and 6:00am.
The scheduling syntax is incredibly powerful and flexible. You can express just about every possible time imaginable.
0 comments:
Speak up your mind
Tell us what you're thinking... !