1. Edit the Scheduled task list using the CRONTAB-E commandThe list of scheduled tasks edited with this command is user-level, and a file with the same user name is generated in the/var/spool/cron directory after the first edit, and the file content is our scheduled task list. If there is no scheduled task, this file is an empty file.The crontab command also has some other options-U #指定哪个用户的cron服务, which is
"The basic composition of Crontab"① system service CROND: Refreshes the scheduled task from the configuration file every minute② configuration file : Set up timed tasks by file mode③ Configuration Tool crontab: Use to adjust timed tasksConfiguration file format for profile* * * * * COMMANDThe first *: minutes 0-59,* means to execute every minuteSecond *: hours 0-23Third one *: date 1-31Fourth one *: month 1
The Mid-Autumn Festival is coming, first of all wish yourself a happy mid-autumn.Yesterday six o'clock in the afternoon, the heart is thinking of adding a crontab can work. Originally wanted to execute CRONTAB-E, did not think of hand shake on the input of crontab, and then entered the following look.When you see something wrong, press Ctrl + D.Then, the horrible
Crontab avoids repeated tests that have not been executed within the cycle. crontab instance
If a script is running for 30 minutes, you can set the script interval to at least one hour in Crontab to avoid conflicts. The worst case is that the script is not completed within the execution cycle, and the second script starts to run again. How can we ensure that only
① 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
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
There is a crash CT script to remotely restart the processes on the target server. Everything is OK when it is executed separately under shell, but it cannot be executed when it is added to the cron task. Some code is as follows:
Secondary CT Script: (/data/home/restart_secondary CT)
#! /Usr/bin/CT
Spawn ssh-p xxx root@xxx.xxx.xxx.xxx
# Keep CT "* Root's password *"Secondary CT "* Tencent :*"
Send "Sh some remote scripts"Send "Exit/N"
Ct eof exit 0
Crontab
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
Started yesterday, has been working through the timer task to control the screen, a single command under the terminal can be executed successfully, write to the script, a single execution script can be successful, but write to the crontab timed task, how do not put out the screen, but he did execute, look at the log, is always error; Baidu a lot of many, Basically are the reasons for environmental variables, and then tried and tried, has not been, the
The common user crontab task is not executed, and the common user crontab
Today, in linux, the crontab task of common users is not executed. I have searched a lot on the Internet. I 'd like to add the following content before the executed script.
If [-f ~ /. Bash_profile];Then.~ /. Bash_profileFi
It does not work after being added. I don't know if it works o
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
Cron is the next program in the Linux system that automatically executes a specified task.The cron service is a built-in service for Linux, but it does not boot automatically. You can start and stop the service with the following command:Linux Code
/sbin/service Crond Start
/sbin/service Crond Stop
/sbin/service Crond Restart
/sbin/service Crond Reload
The above 1-4 lines start, stop, restart the service, and reload the configuration, respectively.To set cron to start automatically wh
Tags: tom dai mail mysql ack path ntpd Mon penLinux configuration timed tasks, we all know the use of crontab this system function, but sometimes we need to distinguish between user execution, the following directly say the difference between the 2 ways:Method 1:Use the command crontab-e and edit the timed script directly.After this execution, the user-defined, will be written to the/var/spool/cron director
CronTab command instance and crontab instanceWrite the date to time. log every 2 minutes (the following is an odd number of minutes for execution)
*/2 * date> ~ /Time. log
1-59/2 * date> ~ /Time. log
Restart apache at every day
30 23 ***/etc/init. d/apache2 restartRestart apache30 23, 10, 20 **/etc/init. d/apache2 restart at on the first day of every month
Restart apache at every month from.
30 23 1-1
execution is performed every n hours, and so on.When f1 is a, B, c ,... a, B, c ,... execute in minutes. f2 is a, B, c ,... a, B, c... execution in hours, and so onYou can also store all the settings in the file and use crontab file to set the time table.InstanceRun the Command/bin/ls once every 0th minutes of every hour every month.0 7 ***/bin/lsDuring October 11, December, the/usr/bin/backup task is executed every 20 minutes from to every day.0 6-1
/var/log/cron File Save Cron task execution recordCD/var/log/-L cron*Will find a cron log change every day.UseTail-f CronAbility to view logs for today's cron:UseCat/etc/crontabCan seeMailto=root means that when a crontab command or task is executed, a record message is generated to the root userView Root's Mail[[Email protected] cron]# CD/var/spool/mail[[email protected] mail]# pwd/var/spool/ Mail[[email protected] mail]# Lsdee Emperor mysql root
The Linux system is controlled by the cron (Crond) system service. Linux systems have a lot of planned work on them, so this system service is started by default. In addition, because the user can set up scheduled tasks themselves, the Linux system also provides a command for the user to control scheduled tasks: the crontab command.I. Introduction of CrondCrond is a daemon that is used to periodically perform certain tasks or wait for certain events u
I always think that timer is a better way to implement the timer. Later, I found out the disadvantage of timer only when I used Linux commands to create scheduled tasks, in timer, it is very likely that your task will be killed as a dead program ...... the last time a colleague accidentally used a timer task as a dead program to kill it, he reported an error to know that a timer was circulating. for many reasons, the following are excerpted content.
Name: cr
I. Introduction of CrondCrond is a daemon that is used to periodically perform certain tasks or wait for certain events under Linux, similar to Scheduled tasks under Windows, when the operating system is installed, the Service tool is installed by default and the Crond process is started automatically. The Crond process periodically checks to see if there is a task to perform and automatically executes the task if there are tasks to perform.The task scheduling under Linux is divided into two cat
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.