LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-20-2019, 01:01 PM   #1
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Rep: Reputation: Disabled
Crontab works for root but not non-root user


I'm new to ubuntu but since I can get the root crontab working, I must be doing something right.

I'm running release 18.04 codename bionic

In my research I found that a common mistake is to not have a blank line at the bottom of the crontab file. That is not my problem, because there is a blank line at the bottom of my crontab file located in /var/spool/cron/crontabs/(username).

Where can I find the log for the non-root user?
/var/log/cron does not exist.

The root crontab logs in /var/log/syslog

I'm sorry if this has already been answered. It seems that the answers vary depending on the version of linux.

Last edited by Tem2; 01-21-2019 at 10:40 AM.
 
Old 01-20-2019, 02:25 PM   #2
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Why does my screen go to sleep!

A little more info...

My main problem is that my screen goes to sleep sometimes while I'm watching streaming video.

I'm hoping that the following commands will eliminate this going to sleep problem:

/usr/bin/xset s off
/usr/bin/xset s noblank
/usr/bin/xset s -dpms
/usr/bin/xset s noexpose

These commands work with just the xset command, but I've added the path because the cron job fails if I don't.

If I run the commands from a terminal, there is no error. For some reason though the screen-saver parameter "allow exposures" keeps changing back to yes (see red highlight in xset q command output below)

master@master-Latitude-D630:~$ xset q
Keyboard Control:
auto repeat: on key click percent: 0 LED mask: 00000000
XKB indicators:
00: Caps Lock: off 01: Num Lock: off 02: Scroll Lock: off
03: Compose: off 04: Kana: off 05: Sleep: off
06: Suspend: off 07: Mute: off 08: Misc: off
09: Mail: off 10: Charging: off 11: Shift Lock: off
12: Group 2: off 13: Mouse Keys: off
auto repeat delay: 500 repeat rate: 33
auto repeating keys: 00ffffffdffffbbf
fadfffefffedffff
9fffffffffffffff
fff7ffffffffffff
bell percent: 50 bell pitch: 400 bell duration: 100
Pointer Control:
acceleration: 5/1 threshold: 5
Screen Saver:
prefer blanking: no allow exposures: yes
timeout: 0 cycle: 0
Colors:
default colormap: 0x20 BlackPixel: 0x0 WhitePixel: 0xffffff
Font Path:
/usr/share/fonts/X11/misc,/usr/share/fonts/X11/Type1,built-ins
DPMS (Energy Star):
Standby: 0 Suspend: 0 Off: 0
DPMS is Disabled



I have no idea if this strategy will stop my screen from going to sleep.



Here is the mail I receive related to the cron jobs: I'm guessing the "unable to open display" is the problem, but I don't know what to do.

From master@master-Latitude-D630 Sun Jan 20 15:17:01 2019
Return-Path: <master@master-Latitude-D630>
X-Original-To: master
Delivered-To: master@master-Latitude-D630
Received: by master-Latitude-D630 (Postfix, from userid 1000)
id 9110F7FC3C; Sun, 20 Jan 2019 15:17:01 -0500 (EST)
From: root@master-Latitude-D630 (Cron Daemon)
To: master@master-Latitude-D630
Subject: Cron <master@master-Latitude-D630> /usr/bin/xset s -dpms >> cronlog
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/master>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=master>
Message-Id: <20190120201701.9110F7FC3C@master-Latitude-D630>
Date: Sun, 20 Jan 2019 15:17:01 -0500 (EST)

/usr/bin/xset: unable to open display ""

From master@master-Latitude-D630 Sun Jan 20 15:17:01 2019
Return-Path: <master@master-Latitude-D630>
X-Original-To: master
Delivered-To: master@master-Latitude-D630
Received: by master-Latitude-D630 (Postfix, from userid 1000)
id BEB3B7FC3C; Sun, 20 Jan 2019 15:17:01 -0500 (EST)
From: root@master-Latitude-D630 (Cron Daemon)
To: master@master-Latitude-D630
Subject: Cron <master@master-Latitude-D630> /usr/bin/xset s noblank >> cronlog
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/master>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=master>
Message-Id: <20190120201701.BEB3B7FC3C@master-Latitude-D630>
Date: Sun, 20 Jan 2019 15:17:01 -0500 (EST)

/usr/bin/xset: unable to open display ""

From master@master-Latitude-D630 Sun Jan 20 15:17:01 2019
Return-Path: <master@master-Latitude-D630>
X-Original-To: master
Delivered-To: master@master-Latitude-D630
Received: by master-Latitude-D630 (Postfix, from userid 1000)
id D5FCE84300; Sun, 20 Jan 2019 15:17:01 -0500 (EST)
From: root@master-Latitude-D630 (Cron Daemon)
To: master@master-Latitude-D630
Subject: Cron <master@master-Latitude-D630> /usr/bin/xset s off >> cronlog
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/master>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=master>
Message-Id: <20190120201701.D5FCE84300@master-Latitude-D630>
Date: Sun, 20 Jan 2019 15:17:01 -0500 (EST)

/usr/bin/xset: unable to open display ""

From master@master-Latitude-D630 Sun Jan 20 15:17:02 2019
Return-Path: <master@master-Latitude-D630>
X-Original-To: master
Delivered-To: master@master-Latitude-D630
Received: by master-Latitude-D630 (Postfix, from userid 1000)
id E5AA28430A; Sun, 20 Jan 2019 15:17:01 -0500 (EST)
From: root@master-Latitude-D630 (Cron Daemon)
To: master@master-Latitude-D630
Subject: Cron <master@master-Latitude-D630> /usr/bin/xset s noexpose >> cronlog
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/master>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=master>
Message-Id: <20190120201701.E5AA28430A@master-Latitude-D630>
Date: Sun, 20 Jan 2019 15:17:01 -0500 (EST)

/usr/bin/xset: unable to open display ""

From master@master-Latitude-D630 Sun Jan 20 15:17:02 2019
Return-Path: <master@master-Latitude-D630>
X-Original-To: master
Delivered-To: master@master-Latitude-D630
Received: by master-Latitude-D630 (Postfix, from userid 1000)
id A19728430C; Sun, 20 Jan 2019 15:17:01 -0500 (EST)
From: root@master-Latitude-D630 (Cron Daemon)
To: master@master-Latitude-D630
Subject: Cron <master@master-Latitude-D630> /usr/bin/xset s noexpose >> cronlog
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/master>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=master>
Message-Id: <20190120201701.A19728430C@master-Latitude-D630>
Date: Sun, 20 Jan 2019 15:17:01 -0500 (EST)

/usr/bin/xset: unable to open display ""

In the course of troubleshooting this problem, I determined that the crontab only works for my root.

Last edited by Tem2; 01-20-2019 at 02:28 PM.
 
Old 01-20-2019, 03:09 PM   #3
timl
Member
 
Registered: Jan 2009
Location: Sydney, Australia
Distribution: Fedora,CentOS
Posts: 750

Rep: Reputation: 156Reputation: 156
Let's get a bit of information about the crontab issue first. Can you post the output of
Quote:
crontab -l
please. Also how are you modifying crontab? Do you use
Quote:
crontab -e
I guess another question is...what are you doing in root? Typically ubuntu doesn't use root

Cheers
 
Old 01-20-2019, 03:28 PM   #4
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Here is the output of crontab -l

I edit with the crontab -e command

I use root because I don't know what I'm doing

The entry to restart the network manager is something I need because my wireless was dropping without it.

The "hithere" entry is to test crontab.

Any help will be greatly appreciated!


# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
*/5 * * * * /usr/sbin/service network-manager restart
* * * * * echo "hi3 there" >> /home/master/hithere.txt
* * * * * /usr/bin/xset s off >> cronlog
* * * * * /usr/bin/xset s noblank >> cronlog
* * * * * /usr/bin/xset s noexpose >> cronlog
* * * * * /usr/bin/xset s -dpms >> cronlog
* * * * * /usr/bin/xset s noexpose >> cronlog
 
Old 01-20-2019, 04:38 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Cron isn't attached to the desktop which is why you see the can not open display error. You can fix the problem by the following as the cron command.

export DISPLAY=:0 && /use/bin/xset s off

Although you should be able to configure your settings via the following.

https://wiki.archlinux.org/index.php...ment_Signaling
 
Old 01-20-2019, 05:02 PM   #6
Corvette
Member
 
Registered: Jul 2017
Location: Missouri, United States
Distribution: Debian 9
Posts: 110

Rep: Reputation: 24
If I am understanding you correctly, you just want to prevent your screen from going to sleep? If so, you should be able to do this quite simply through the System Settings GUI. What desktop environment do you have? If you have KDE, try either System Setting -> Hardware -> Power Saving -> Screen Energy Saving and/or perhaps System Settings -> Workspace -> Desktop Behavior -> Screen Locking.
 
Old 01-20-2019, 05:18 PM   #7
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
When I run echo $DESKTOP_SESSION it says "unity"

I have tried all of the obvious GUI solutions to no avail.
 
Old 01-20-2019, 05:50 PM   #8
urbanwks
Member
 
Registered: Sep 2003
Distribution: Slackware64-Current, FreeBSD 12.1, Alpine 5.4, Manjaro 19, Alpine on WSL [Win10]
Posts: 194

Rep: Reputation: 213Reputation: 213Reputation: 213
I am assuming this does not work?: https://help.ubuntu.com/stable/ubunt...-blank.html.en
 
Old 01-20-2019, 05:55 PM   #9
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Cron isn't attached to the desktop which is why you see the can not open display error. You can fix the problem by the following as the cron command.

export DISPLAY=:0 && /use/bin/xset s off

Although you should be able to configure your settings via the following.

https://wiki.archlinux.org/index.php...ment_Signaling
https://wiki.archlinux.org/index.php...ment_Signaling
Prevent screen from turning off

You can run this command:

$ setterm -blank 0 -powerdown 0


Output:
master@master-Latitude-D630:~$ setterm -blank 0 -powerdown 0
setterm: terminal xterm-256color does not support --blank
[14;0]master@master-Latitude-D630:~$

Alternatively you can disable console blanking permanently using the following command:

# echo -ne "\033[9;0]" >> /etc/issue


I was able to edit the /etc/issue file to add this entry. Not sure what it is going to do!
 
Old 01-20-2019, 06:11 PM   #10
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by urbanwks View Post
https://help.ubuntu.com/stable/ubunt...-blank.html.en
Set screen blanking time

To save power, you can adjust the time before the screen blanks when left idle. You can also disable the blanking completely.
To set the screen blanking time:

Open the Activities overview and start typing Settings.

Click on Settings.

Click Power in the sidebar.

Use the Blank screen drop-down list under Power Saving to set the time until the screen blanks, or disable the blanking completely.


I'm guessing these instructions are just to get me to the GUI settings. I get there by clicking on the gear icon in the very top right corner and selecting System Settings from the drop down menu. The settings are:

BRIGHTNESS AND LOCK
Turn screen off when inactive for "Never"
Lock is OFF

POWER
Suspend when inactive for "Don't suspend" (both on battery power and when plugged in)
 
Old 01-24-2019, 09:04 PM   #11
B-RAH
LQ Newbie
 
Registered: Jun 2017
Distribution: HP-UX, Red Hat, Fedora, AIX, Solaris
Posts: 13

Rep: Reputation: Disabled
Question Dumb Question

I just thought I would ask since I haven't seen it on this thread, but have you checked /etc/cron.allow or /etc/cron.deny? cron should work for root out of the box, and if for some reason you DO have an /etc/cron.allow file and it's blank, no users can run crontab and you need to put your users in the file. I don't know why you would have that file, and I highly doubt that's the issue, but it's a super easy thing to check that has not been mentioned.
 
Old 01-25-2019, 01:13 PM   #12
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by B-RAH View Post
I just thought I would ask since I haven't seen it on this thread, but have you checked /etc/cron.allow or /etc/cron.deny? cron should work for root out of the box, and if for some reason you DO have an /etc/cron.allow file and it's blank, no users can run crontab and you need to put your users in the file. I don't know why you would have that file, and I highly doubt that's the issue, but it's a super easy thing to check that has not been mentioned.
Thanks for the suggestion. There is no cron.allow or cron.deny file in the /etc directory.

The problem has not been resolved.
 
Old 01-28-2019, 08:45 PM   #13
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
FYI the problem went away when I reinstalled ubuntu. Thanks for all the assistance!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] DBD::ODBC works as root but not as non-root user on CentOS5 - any ideas? prgupta Red Hat 2 07-13-2010 12:20 AM
[SOLVED] Crontab not working for non-root User ferventslacker Linux - Newbie 5 01-19-2010 09:50 AM
LDAP Authentication Fails for Non-Root, but works for root ludwig Linux - Server 2 08-16-2008 05:53 PM
cdrecord works for root, but not non-priviledged user mpdegroat Linux - Software 3 05-24-2004 11:15 AM
IntelliMouse thumb buttons work as root, broken as non-root user, wheel works always digital vortex Linux - Hardware 7 03-02-2004 04:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration