Linux issue: Crontab a problem with relative paths when executing shell scripts, not recognized.

Source: Internet
Author: User

Problem Description: The direct execution shell script in Linux can find the file with a relative path, but if you execute the shell script through the scheduled task crontab, you cannot find the file by relative path!

Example:

Shell script file Code ~

#! /bin/sh'./1.txt'; Date >> $Logfile; Echo ' ------ ';

Execute the shell script directly, you can see the result in the 1.txt file, but if the task is executed with crontab, it will not be seen in the 1.txt execution result. Change to an absolute path, the code is as follows

#! /bin/sh= 'pwd'/1.txt'; Date >> $Logfile; Echo ' ----- ';

Linux issue: Crontab a problem with relative paths when executing shell scripts, not recognized.

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.