0

I am a completely newbie in Ubuntu/Linux.
I am trying to get some scheduled tasks, but no success until now.
I am running Ubuntu 16.04

I am trying to use cron to fix the brightness of the screen. I am using this code:

56 * * * * /usr/bin/xrandr --output HDMI1 --brightness 0.1 # JOB_ID_7

The code is running OK on terminal (without the minutes and ***), but not as cron scheduled task.

I've tried also with relative patch (withouth /usr/bin/).

When looking at syslog, I've seen that:

Dec 10 10:56:01 LIQ03 cron[634]: (liq03) RELOAD (crontabs/liq03)
Dec 10 10:56:02 LIQ03 CRON[3586]: (liq03) CMD (/usr/bin/xrandr --output HDMI1 --brightness 0.1 # JOB_ID_7)
Dec 10 10:56:02 LIQ03 CRON[3585]: (CRON) info (No MTA installed, discarding output)

So, I understand I have no MTA installed, which I don't know how to install... Any advice?


I have installed postfix to see if now the task runs OK, but no chance. The screen is not dimmed anyway.
So, I am thinking that, anyway, the task should run even if postfix is not installed...

/Var/log/syslog reports that:

Dec 10 11:43:01 LIQ03 cron[634]: (liq03) RELOAD (crontabs/liq03)
Dec 10 11:43:01 LIQ03 CRON[5487]: (liq03) CMD (/usr/bin/xrandr --output HDMI1 --brightness 0.1 # JOB_ID_7)
Dec 10 11:43:01 LIQ03 postfix/pickup[5391]: 1EB7C1611FE: uid=1000 from=<liq03>
Dec 10 11:43:01 LIQ03 postfix/cleanup[5491]: 1EB7C1611FE: message-id=<20161210104301.1EB7C1611FE@LIQ03.homestation>
Dec 10 11:43:01 LIQ03 postfix/qmgr[5392]: 1EB7C1611FE: from=<liq03@LIQ03@liq03.com>, size=622, nrcpt=1 (queue active)
Dec 10 11:43:01 LIQ03 postfix/error[5493]: 1EB7C1611FE: to=<liq03@LIQ03@liq03.com>, orig_to=<liq03>, relay=none, delay=0.05, delays=0.03/0.01/0/0.01, dsn=5.0.0, status=bounced (liq03.com)
Dec 10 11:43:01 LIQ03 postfix/cleanup[5491]: 28D271630F8: message-id=<20161210104301.28D271630F8@LIQ03.homestation>
Dec 10 11:43:01 LIQ03 postfix/qmgr[5392]: 28D271630F8: from=<>, size=2561, nrcpt=1 (queue active)
Dec 10 11:43:01 LIQ03 postfix/bounce[5494]: 1EB7C1611FE: sender non-delivery notification: 28D271630F8
Dec 10 11:43:01 LIQ03 postfix/qmgr[5392]: 1EB7C1611FE: removed
Dec 10 11:43:01 LIQ03 postfix/error[5493]: 28D271630F8: to=<liq03@LIQ03@liq03.com>, relay=none, delay=0.01, delays=0.01/0/0/0.01, dsn=5.0.0, status=bounced (liq03.com)
Dec 10 11:43:01 LIQ03 postfix/qmgr[5392]: 28D271630F8: removed
3

The problem you experience is not the missing MTA, which just disables cron to send mails.

The reason that your cronjob is not executed is, that it is run in a different environment than your X session and therefore the cronjob does not have access to the screen.
What you need inside the cronjob is the information about which display xrandr should use and the authority to use the display specified. Normally you can use the following in your crontab to make it work.

56 * * * * XAUTHORITY="/var/run/lightdm/root/:0" /usr/bin/xrandr --display :0 --output HDMI1 --brightness 0.1 # JOB_ID_7

You might have to change the content of the XAUTHORITY variable depending on your display manager and configuration.
Maybe easiest way to find that is to run the following command and look for the string after -auth.

user@host:~# ps aux | grep Xorg
root      2604  1.4  3.0 265236 44960 tty7     Ssl+ 12:48   0:00 /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
  • Great, it works now!!! In my case it was the same content for Xauthority, so it runs perfectly now!! – escombralls Dec 10 '16 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.