[Solved] cron.daily doesn't raise xterm

Kernels & Hardware, configuring network, installing services

[Solved] cron.daily doesn't raise xterm

Postby bester69 » 2018-06-21 11:12

Its running the script as log files are being completed, but it doent opent a xterm terminal, neither a konsole terminal. When I use run-parts for testing it, It does open the terminals... :?: :?:

Code: Select all
#!/bin/sh
#
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
fechaname=hardback-`date +%Y-%m-%d_%H:%M:%S`.log
su myuser -c "/home/myuser/scripts/hardback.sh" | tee /home/myuser/LINUXDEBS/NOBACKUP/logs/$fechaname
su myuser -c "konsole --hold -e more /home/myuser/LINUXDEBS/NOBACKUP/logs/$fechaname"
su myuser -c "xterm -hold -e more /home/myuser/LINUXDEBS/NOBACKUP/logs/$fechaname"


Any help? :( , Thanks
Last edited by bester69 on 2018-06-22 10:21, edited 1 time in total.
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
User avatar
bester69
 
Posts: 1201
Joined: 2015-04-02 13:15

Re: cron.daily doesn't raise xterm

Postby bw123 » 2018-06-21 13:09

man su will explain the env that gets preserved under different circumstances. Also there are a lot of results with this
https://duckduckgo.com/html/?q=cron+open+terminal
User avatar
bw123
 
Posts: 3278
Joined: 2011-05-09 06:02
Location: TN_USA

Re: cron.daily doesn't raise xterm

Postby reinob » 2018-06-21 17:02

bester69 wrote:Its running the script as log files are being completed, but it doent opent a xterm terminal, neither a konsole terminal. When I use run-parts for testing it, It does open the terminals... :?: :?:

Code: Select all
#!/bin/sh
#
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
fechaname=hardback-`date +%Y-%m-%d_%H:%M:%S`.log
su myuser -c "/home/myuser/scripts/hardback.sh" | tee /home/myuser/LINUXDEBS/NOBACKUP/logs/$fechaname
su myuser -c "konsole --hold -e more /home/myuser/LINUXDEBS/NOBACKUP/logs/$fechaname"
su myuser -c "xterm -hold -e more /home/myuser/LINUXDEBS/NOBACKUP/logs/$fechaname"


Any help? :( , Thanks


Well cron.daily runs as root so I don't know how you expect that to work (hint: imagine nobody is logged in, where should xterm show up?).

cron is not (designed) for interactive things. If you really insist in (ab)using it for that purpose, use at least the user's cron, so that you don't need the "su myuser -c".

Note also that before konsole or xterm can do anything graphical they need to know where they are supposed to show up, i.e. at the very least you should set the DISPLAY environment variable to something sensible.

On top you have the whole session/dbus/pam/systemd/policykit mess to deal with. But first things first.. (it won't work anyway).
reinob
 
Posts: 546
Joined: 2014-06-30 11:42

Re: cron.daily doesn't raise xterm

Postby bester69 » 2018-06-21 21:16

reinob wrote:Well cron.daily runs as root so I don't know how you expect that to work (hint: imagine nobody is logged in, where should xterm show up?).

cron is not (designed) for interactive things. If you really insist in (ab)using it for that purpose, use at least the user's cron, so that you don't need the "su myuser -c".

Note also that before konsole or xterm can do anything graphical they need to know where they are supposed to show up, i.e. at the very least you should set the DISPLAY environment variable to something sensible.

On top you have the whole session/dbus/pam/systemd/policykit mess to deal with. But first things first.. (it won't work anyway).

Thanks for answering, I think DISPLAY environment will work, It had already triggered xterm and konsole in a test script.

Code: Select all
DISPLAY=:0 ; export DISPLAY
su myuser -c "xterm -display :0 -hold -e ls"
su myuser -c "konsole --hold -e ls"


Thanks again, I really apreciate it :)
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
User avatar
bester69
 
Posts: 1201
Joined: 2015-04-02 13:15

Re: cron.daily doesn't raise xterm

Postby Head_on_a_Stick » 2018-06-22 04:55

A systemd timer unit enabled for the user would be better suited to this, see systemd.timer(5) for the details.
User avatar
Head_on_a_Stick
 
Posts: 7904
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: cron.daily doesn't raise xterm

Postby bester69 » 2018-06-22 10:20

Head_on_a_Stick wrote:A systemd timer unit enabled for the user would be better suited to this, see systemd.timer(5) for the details.

Thanks Head,
I will take it a look , by now it's working old way

Code: Select all
#!/bin/sh
################# HARDLINKS SDA3
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
fechaname=hardback-SDA3`date +%Y-%m-%d_%H:%M:%S`.log
su myuser -c "/home/myuser/scripts/hardback_SDA3.sh" | tee /home/myuser/LINUXDEBS/NOBACKUP/logs/$fechaname

DISPLAY=:0 ; export DISPLAY
su myuser -c "konsole -e more  /home/myuser/LINUXDEBS/NOBACKUP/logs/$fechaname"

exit 0
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
User avatar
bester69
 
Posts: 1201
Joined: 2015-04-02 13:15


Return to System configuration

Who is online

Users browsing this forum: 1885 and 8 guests

fashionable