Crontab This pit, execute a single command execution succeeds, but write to crontab.

Source: Internet
Author: User

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 afternoon in the group asked, a big brother to me step by step analysis, and then understand:

Crontab executes the task in the system, the execution of the time is no terminal;

My idea is that since there's no terminal, I'm going to get you a terminal to execute this screen command:

*/1 * * * * export display=:0.0"xset DPMS Force off && exit  2>>/tmp/log< /c3>"

Export display=:0.0 Set the environment variable to this to open the terminal

Gnome-terminal: Open a terminal

Gnome-terminal--maximize: Maximize after opening a terminal

Gnome-terminal--full-screen: Full screen after opening a terminal

-C <string> Run the following string to represent the command or script. A semicolon indicates that multiple commands are executed sequentially

Write the questions you encounter, and when you see them, you may bring a hint of inspiration, hehe.

Encounter problems must be calm, step by step troubleshooting, not too anxious, the log is a very important thing, the principle is also a very important thing!!!

Crontab This pit, execute a single command execution succeeds, but write to crontab.

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.