Crontab and shell scripts to implement Linux timing tasks __linux

Source: Internet
Author: User

The writing of Linux shell scripts

VI test.sh

#!/bin/bash

###################
. /etc/profile
. ~/.bash_profile
##################

Path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Cd/home/huaxia/syslog2db&&ruby app.rb Stop
Cd/home/huaxia/syslog2db&&ruby app.rb Start

After saving, authorize chmod +x./test.sh

Execute./TEST.SH can run correctly the presentation script is written correctly

Linux Crotab Edit


Input CROTAB-E into the scheduled task editing interface
Write the script that needs to be run, and the time the configuration runs is as follows:
* 7 * * * * * */root/test.sh>/dev/null 2>&1 (indicates that the script is run at 7 o ' clock every day, the script is in the full path,> after the mask stdout and stderr output)
(You can specify the path of the output when debugging: * 7 * * * */root/test.sh>>/home/test.txt)


Environment variable Configuration Statement Path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Personally think that you have to add (if you encounter a timer does not work, but the manual execution of the script normally can be judged that the environment variable is not introduced)
Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.