[Shell]crontab Run task calls Shell script, relative path cannot be found

Source: Internet
Author: User
Tags python script

The scene of the problem is probably


1 Cron calls a Python script

2 python script calls a shell script (for log parsing) to get the shell output and then send the message

Similar to a monitoring task.


There is no problem running the Python script directly, but after writing it in Cron. The relative path in the shell script cannot be found, always prompting that some files cannot be found

The problem was solved by using the absolute path of the log file, and the execution was normal.


Google a few, found that very many people have encountered similar problems, may be related to the cron mechanism.


Most people's problems are caused by environmental variables. Because Cron is a standalone process, it is not a user login, and so on. So some programs will not run successfully.

Similar: http://stackoverflow.com/questions/2388087/how-to-get-cron-to-call-in-the-correct-paths


But from the very many people's script basically is absolute path. Perhaps I write too little, very many principles and principles are not very clear.


This article is derived from "Orangleliu notebook " ? blog, be sure to keep this source http://blog.csdn.net/orangleliu/article/details/38641417


[Shell]crontab Run task calls Shell script, relative path cannot be found

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.