Setting Up Cron Job Using crontab
2018-01-21 21:09
337 查看
Setting Up Cron Job Using
crontab:
Step 1: Open a Terminal Window (Command Line) in Linux.
Step 2:
The following is a list of cron directories:•
/etc/cron.hourly
• /etc/cron.daily
• /etc/cron.weekly•
/etc/cron.monthly
Copy your shell script ‘script.sh` or ‘script’ into one of the directories above.If you need to run the script hourly, place your script file in the “cron.hourly”folder. For daily, place it inside
the “cron.daily” and so forth.
Step 3:
Give the shell script the correct permission. For example, if script is called“script.sh”, set permission as follows:
cd /etc/cron.daily/chmod 755 script.sh
Step 4:
Add new cron job to crontab:
crontab –e
This opens vi editor for you. Create the cron command using the following syntax:
1.2.3.4.5.6.
More
The number of minutes after the hour (0 to 59)
The hour in military time (24 hour) format (0 to 23)The day of the month (1 to 31)
The month (1 to 12)
The day of the week(0 or 7 is Sun, or use name)The command to run
graphically they would look like this:
* * * * * Command to be executed-----|||||
| |
| |
| |
An example command would be
“0 0 * * * /etc/cron.daily/script.sh”. Thiswould mean that the shell script will exactly execute at midnight
everynight.
To save the changes to the crontab that you just made, hit ESC key, andthen type
:w
followed by
:q
to exit.
To list existing cron jobs:
crontab –l
To remove an existing cron job:
Enter:
crontab –e
Delete the line that contains your cron job•
HitESC>:w>:q
crontab:
Step 1: Open a Terminal Window (Command Line) in Linux.
Step 2:
The following is a list of cron directories:•
/etc/cron.hourly
• /etc/cron.daily
• /etc/cron.weekly•
/etc/cron.monthly
Copy your shell script ‘script.sh` or ‘script’ into one of the directories above.If you need to run the script hourly, place your script file in the “cron.hourly”folder. For daily, place it inside
the “cron.daily” and so forth.
Step 3:
Give the shell script the correct permission. For example, if script is called“script.sh”, set permission as follows:
cd /etc/cron.daily/chmod 755 script.sh
Step 4:
Add new cron job to crontab:
crontab –e
This opens vi editor for you. Create the cron command using the following syntax:
1.2.3.4.5.6.
More
The number of minutes after the hour (0 to 59)
The hour in military time (24 hour) format (0 to 23)The day of the month (1 to 31)
The month (1 to 12)
The day of the week(0 or 7 is Sun, or use name)The command to run
graphically they would look like this:
* * * * * Command to be executed-----|||||
| |
| |
| |
| +----------- Hour (0 - 23) +------------- Min (0 - 59)
| | +----- Day of week (0-7) | +------- Month (1 - 12) +--------- Day of month (1 - 31)
An example command would be
“0 0 * * * /etc/cron.daily/script.sh”. Thiswould mean that the shell script will exactly execute at midnight
everynight.
To save the changes to the crontab that you just made, hit ESC key, andthen type
:w
followed by
:q
to exit.
To list existing cron jobs:
crontab –l
To remove an existing cron job:
Enter:
crontab –e
Delete the line that contains your cron job•
HitESC>:w>:q
相关文章推荐
- Unix Crontab - setting up cron jobs using crontab
- [转]Setting up an ASP.NET website development environment using Visual Studio .NET, Subversion, and Windows XP
- 转-Quick guide to setting up SSL using Domino as the Certificate Authority
- Automatic import using Magento cron job
- WP REST API: Setting Up and Using Basic Authentication
- Setting up Ethereum smart contract development using Parity on Ubuntu
- Setting up a local development plattform on windows using xampp
- WP REST API: Setting Up and Using OAuth 1.0a Authentication
- Setting up a local development plattform on windows using xampp
- Setting Up NAT on Solaris Using IP Filter
- Setting up flash chat application using project Darkstar
- Setting Up Database Mirroring Using Certificates
- Setting Up NAT on Solaris Using IP Filter
- cronjob & crontab
- cronjob & crontab
- Quick guide setting up Debian with SATA RAID using grub2 (Squeeze, Lenny, etc)
- Setting up and using the Rational Data Architect - Rational ClearCase integration
- Transmitting Network Data Using Volley - Setting Up a RequestQueue
- 转:Setting Up IoC in ASP.NET MVC using Castle Windsor