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
Introduction to the Crontab command for executing scheduled tasks in Centos
1. Start and Stop Cron
Since Cron is a built-in service in Linux, you can use the following method to start and close the service:
/Sbin/service crond start // start the service/Sbin/service crond stop // close the service/Sbin/service crond restart // restart the service/Sbin/service crond reload // reload the configuration
2. Cron configuration file
2.1 global configuration
1. Start and Stop Cron
Since cron is a built-in service in Linux, you can use the following method to start and close the service:
/Sbin/service crond start // start the service/Sbin/service crond stop // close the service/Sbin/service crond restart // restart the service/Sbin/service crond reload // reload the configuration
2. cron configuration file
2.1 global configuration file
Crontab contains cron. Hourly, cron. daily, cron. Weekly, cron.
a/etc/crontab, so we configure this file can also use the Cron service to do something. The crontab configuration is for a user, while the edit/etc/crontab is a task for the system. The file format for this file is:Shell=/bin/bashPath=/sbin:/bin:/usr/sbin:/usr/binMailto=root//If an error occurs, or if there is data output, the data is sent to this account as an
a/etc/crontab, so we configure this file can also use the Cron service to do something. The crontab configuration is for a user, while the edit/etc/crontab is a task for the system. The file format for this file is:Shell=/bin/bashPath=/sbin:/bin:/usr/sbin:/usr/binMailto=root//If an error occurs, or if there is data output, the data is sent to this account as an
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
e-mail message to theuser name defined by the M ailto variable. If the MAILTO variable is defined as an empty string (mailto= ""), the e-mail message is not sent. The home variable can be used to set the base directory when executing a command or script. Each line of the task in the file/etc/crontab is described in the following format: minute hour day month DayOfWeek command minute -integers from 0 to 59hour -integers from 0 to 23 Day-an integer f
command is executed monthly (subject to other restrictions ). the hyphen (-) between integers denotes an integer sequence , for example 1-4 means integers 1,2,3,4 The specified value is separated by commas. Such as: 3,4,6,8 represents these four specified integers. the symbol "/" specifies the stepping setting. "/" indicates a stepping value. such as the 0-59/2 definition is executed every two minutes. The step value can also be represented by an
service after the modification. The system level configuration file of the/etc/crontab configuration file cron is located in/etc/crontab. The cron service reads not only all files in/var/spool/cron every minute, but also the/etc/crontab configuration file once, therefore, we can use the cron service to configure this file. The configuration with
to tranferfiles. Sh>; tranferfiles. LogDo not forget to start the scheduled service after the settings are complete (most of them forget this)[Root @ test1 init. d] # service crond stop[Root @ test1 init. d] # service crond startOr/Etc/init. d/crontab start
Note:The crontab command schedules the execution of some commands at certain intervals. There is a crontab
execution of scripts within/etc/cron.hourly4 * * * root run-parts/etc/cron.daily //daily execution of scripts within/etc/cron.daily4 * * 0 root run-parts/etc/cron.weekly//weekly execution of scripts within/etc/cron.weekly4 1 * * Root run-parts/etc/cron.monthly//monthly to execute scripts within/etc/cron.monthly attention to the "run-parts" This parameter, if you remove this parameter, you can later write to run a script name, not the folder name.
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
read all the files within/var/spool/cron, but also to read a/etc/crontab, so we configure this file can also use the Cron service to do something. The crontab configuration is for a user, while the edit/etc/crontab is a task for the system. The file format for this file is:Shell=/bin/bashPath=/sbin:/bin:/usr/sbin:/usr/binMailto=root//If an error occurs, or if th
The implementation of Linux timing tasks are: cron, Anacron, at, and so on, here mainly about cron services.Noun Explanation:Cron is the service name, Crond is a background process, and crontab is a custom-made scheduled task table.Package Installation:To use the Cron service, install the Vixie-cron package and the Crontabs package first, and the two packages function as follows:The Vixie-cron package is the main program for Cron.The Crontabs package
also to read a/etc/crontab, so we configure this file can also use the Cron service to do something. The crontab configuration is for a user, while the edit/etc/crontab is a task for the system. The file format for this file is:Shell=/bin/bashPath=/sbin:/bin:/usr/sbin:/usr/binMailto=root//If an error occurs, or if there is data output, the data is sent to this a
Tags: and date specification description str mail file name scheduled task Sbincrontab 设置定时任务Syntax format: crontab "option" "File" crontab [options] [file]Attention:
crontab command and subsequent options and files, there must be at least one space between each element
The newly created cron job will not execute immediately, at least 2 minutes. If y
is the symbol description:Special Symbolic meaningsRun Once @reboot reboot@yearly Run once a year, equivalent to: "0 0 1 1 *".@annually mean like @yearly.@monthly Run once a month, equivalent to: "0 0 1 * *".@weekly Run once a week, equivalent to "0 0 * 0".@daily Run once a day, equivalent to "0 0 * * *".@midnight the same as @daily)@hourly run hourly, equivalent to "0 * * * *".Demo Example: Run/root/mkdir.sh every hour:@hourly/root/mkdir. SH/etc/
sent as an e-mail message to the user name defined by the mailto variable. If the MAILTO variable is defined as an empty string (MAILTO=""), the e-mail message is not sent. The home variable can be used to set the base directory when executing a command or script. File/etc/each row of tasks in Crontab is described in the following format: Minute hour day month DayOfWeek command minute-integer hour from 0 to 59-integer from 0 to 23 Day-an integer f
April 06:14 cron.monthly/
-rw-r--r--1 root root 722 April 6 05:59 crontab
drwxr-xr-x 2 root Root 4096 April 06:14 cron.weekly/
which
cron.ddirectory: All files in the directory and subdirectories that match the scheduling syntax are executed
cron.deny: Record users who refused to execute
cron.allow: Records allowed to execute the user, this file has a higher priority, in general, only need to configure a file (see if you need a white list or
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.