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.