Ubuntu: How to install changes to /etc/crontab



Question:

If I want to add lines to my system's /etc/crontab, what do I have to do to get them to take effect?


Background:

I'm trying to set up a machine with Ubuntu 13.04 so that it automatically locks/unlocks the monitor during the workday (it's hanging on the wall).

I've done this by adding the following to my /etc/crontab:

00 18  * * mon-fri myuser export DISPLAY:=0 && gnome-screensaver-command -a  00 18  * * mon-fri myuser export DISPLAY:=0 && xset dpms force standby  00 08  * * mon-fri myuser export DISPLAY:=0 && gnome-screensaver-command -d  00 08  * * mon-fri myuser export DISPLAY:=0 && xset dpms force on  

The individual commands work fine, but I'm trying to test the crontab entries by setting the minute/day to the upcoming minute. For example, at 1:26PM I set the first two columns to 27 13 and waited until the next minute rolled around. But the commands don't appear to be getting executed. I also tried running sudo crontab /etc/crontab, but it doesn't seem to help.


Solution:1

First, you likely need to specify a path to all commands. For example:

00 08  * * mon-fri DISPLAY=:0 /usr/bin/xset dpms force on  

Alternatively, you can put a PATH line at the top of your crontab file. See man 5 crontab.

Second, the system should send cron output to you by email. Check it for error messages.


Solution:2

Upon further debugging, I've determined that running sudo crontab /etc/crontab is actually reloading the crontab and my commands are being run. Looks like it's just a problem with the specific commands. I was able to determine this by adding echo "test" >> /home/myuser/test.txt && to the beginning of the command.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »