The crond service is usually stored in/etc/init. d/crond, so that the crond service can be automatically started after the system starts.
Linux users use the crontab command to configure cron tasks.
Crontab contains cron. d, cron. daily, cron. Weekly, cron. Monthly, cron. Hourly five directories and crontab files u
. For example, if you want to create a backup of some files or folders during your nightly sleep, you can use cron to move from execution. start and stop of services
The cron service is a built-in service for Linux, but it does not boot automatically. You can start and stop a service with the following command:
/sbin/service Crond Start
/sbin/service Crond Stop
/sbin/service Crond Restart
/sbin/service Crond Reload
The above 1-4 lines are start, stop, restart service, and reload the configur
① Environment variablesCD ~pwdIt will go to the root of the user you landed on.Ls-aable to view the. bash_profile fileVim. Bash_profileSome environment variables are set up here.You can set a new environment variable and add it at the end of the file:appdir=/etcexport appdir: wq! Save exitsource. Bash_profileecho $APPDIRIf a global variable is used in a scheduled task, such asCrontab-E Write */1 * * * * echo $APPDIR >>/tmp/appdir.logBut at this point, useTail-f/tmp/appdir.logWhen viewing the log
the settings in the file file, using crontab file to set the schedule.
Example: Data collation www.linuxso.com Linux safety net
0 */2 * * * */sbin/service httpd restart means to restart Apache every two hours
7 * * * */sbin/service sshd start with SSH service 7:50 every day
* * * * */sbin/service sshd stop means shut down SSH service 22:50 every day
0 0 1,15 * * fsck/home 1th and 15th monthly check/home d
records the rejected and allowed to execute the account number, Cron.allow priority is greater than cron.deny, it is recommended to leave only one can cron.daily/hourly/monthly/Weekly: All of these directories are scripts, which are executed at the specified time, respectively. Although the absolute path is crontab executed, it can be understood as a timed trigger for manual execution. However, the path in
, or there is data output. The data is sent to the account HOME as an email = // path for the user to run, here is the root directory # run-parts www.2cto.com 01 ***** root run-parts/etc/cron. hourly // Run/etc/cron hourly. hourly script 02 4 *** root run-parts/etc/cron. daily // Run/etc/cron every day. daily script 22 4 ** 0 root run-parts/etc/cron. weekly // Run/etc/cron every week. weekly script 42 4 1 ** root run-parts/etc/cron. m Onthly // Run/etc/cron every month. note the "run-parts" para
*** root run-parts/etc/cron. Hourly // run the script in/etc/cron. Hourly every hour.
02 4 *** root run-parts/etc/cron. daily // run the script in/etc/cron. daily once a day.
22 4 ** 0 root run-parts/etc/cron. Weekly // run the script in/etc/cron. Weekly once a week.
42 4 1 ** root run-parts/etc/cron. Monthly // run the script in/etc/cron. Monthly every month.
User running path
Note the "run-parts" paramet
Cron is a daemon that can be used to schedule execution of repetitive tasks based on a combination of time, date, month, and week.Cron assumes that the system is running continuously. If the system is not running when a task is scheduled, the task will not be executed.To use the Cron service, you must have the Vixie-cron RPM package installed and you must be running the crond service. To determine if the package is installed, use the rpm-q vixie-cron command. To determine whether the service is
execute scripts that you write yourself. ) in any of the above values, the asterisk (*) can be used to represent all valid values. For example, an asterisk in a month value means that the command is executed monthly after other constraints have been met. A short line between integers (-) to specify an integer range. Such as1-4means an integer1、2、3、4. Specify a list with a series of values separated by commas (,). For example,3,4,6,8indicate these fou
all the scripts under that folderFor each of these statements, the asterisk (*) represents all available values. For example, when referring to month, the command is executed monthly (subject to other restrictions).The hyphen (-) between integers denotes an integer column, for example 1-4 means an integer 1,2,3,4The specified value is separated by commas. Such as: 3,4,6,8 represents these four specified integers.The symbol "/" specifies the stepping
Crontab executes php. crontab executes php.
In linux, we often need to write scheduled tasks. We usually use crontab. For more information about crontab, see the following document:
Http://www.cnblogs.com/peida/archive/2013/01/08/2850483.html
It should be clear that the full qualified name must be used when executin
CronTab Common Errors and crontab Common Errors
Environment Variable
When using environment variables, crontab may fail to normally access the environment variables in bashrc.
Therefore, you should be very careful when using crontab to access environment variables.
Between the third and fifth are "or" operations ("da
root run-parts/etc/cron. weekly // Run/etc/cron every week. weekly script 42 4 1 ** root run-parts/etc/cron. monthly // execute every month /Etc/cron. note the "run-parts" parameter for the script in monthly. If this parameter is removed, you can write a script name to be run later, instead of the folder name. Four instances -------------------------------------- basic format: [parameters must be separated
Crontab scheduled task instance and crontab task instance
Instance 1: Execute myCommand once every minute
* *** MyCommand
Instance 2: 3rd and 15th minutes per hour
3, 15 * myCommand
Instance 3: Run at 3rd and 15th minutes from eight o'clock A.M.
3, 15 8-11 *** myCommand
Instance 4: runs every two days, from eight o'clock A.M. to, at 3rd and 15th minutes.
3, 15 8-11 */2 ** myCommand
Instance 5: runs every 3r
Command | ||||||--command to be executed | |||||--corresponds to the user executing the command, such as Root/username | ||||--week 0~7, can be multi-choice, such as the Monday and Thursday, the Sunday 0/7 synonymous, * mean weekly | |||--month 1~12,* = Monthly | | |--Day 1~31,* means daily | |--hour 1~23,0 means 0 points |--minutes 1~59,* or */1 means every minuteSave after configuration is complete, restart cron servicesudo service cron restartView
The Crond service is typically placed in/etc/init.d/crond so that the Crond service can be started automatically after the system starts.Users in Linux use the crontab command to configure cron tasks.Crontab There are cron.d,cron.daily,cron.weekly,cron.monthly,cron.hourly five directories and crontab files in the/etc directory.CRON.D is a task that the system automatically needs to do on a regular basis, bu
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.