gui - Point ZENITY to CRONTAB: How to - Ask Ubuntu


i running xubuntu 16.04 (lts)

and initial problem was:

  1. how set crontab job shutdown computer every 30 minutes;
  2. how set graphical warning user computer shutdown;

for 1st problem (shutdown 30 minutes) solution easy - searched ask ubuntu , other ubuntu forums , found posts, 1 bellow: how restart every 30 minutes automatically?

after reading post , others realized there diferent options set crontab job:

  • system wide cronjob, located @ /etc/crontab
  • user(s) cronjob, can acessed in terminal crontab -e (crontab -e diferent sudo crontab -e, root crontab)

so having in mind initial crontab output (using crontab located @ /etc/crontab)

*/30 * * * * root shutdown -r +2

this output says computer shutdown (command: shutdown) , reboot (-r) every 30 minutes +2 minutes, warning transmited terminal (if terminal/console open).

please note solution 1st problem worked, refered in link above (https://askubuntu.com/questions/243546...) have use output

*/30 * * * * root /sbin/shutdown -r +2

for example above output works in machine runs elementary os freya 0.3.2. (based on ubuntu 14.04 lts) not run on xubuntu 16.04 computer.

so happy :-) time deal second problem:

"how set graphical warning user computer shutdown"

and not easy solve... understood searches needed kind of application brings dialogs screen. read notify-send , zenity - tested both wanted big notification on screen choose zenity - simple test can made: open terminal , paste this

zenity --warning --text="cristiano ronaldo best"

after needed execute warning under crontab - created simple script (my first 1 :-) ) called aviso.sh , saved in home directory: /home/paulo/

#!/bin/bash

zenity --warning --text="o computador vai desligar-se dentro de 2 minutos. p.f. guarde os seus documentos. obrigado"

after, gave necessary permissions: chmod a+x /home/paulo/aviso.sh

and problems started...i couldn`t gui message warning, despite fact in terminal script worked fine...

i read, , read, , made tests , tests , nothing - decide post in askubuntu question help/instructions

my inital post marked duplicate , given post follow post didn`t work of – david foerster - pointed right direction

so worked? here output:

*/30 * * * * display=:0 /home/paulo/aviso.sh

my initial tests (not working) lead this: 20 20 * * * export no_at_bridge=1 && /home/paulo/aviso.sh

so have learned is: - if display=:0 not present in output gui message not appear in screen; - must specify full path: /home/username/name of script.sh - can acess user crontab typing crontab -e in terminal/console - used crontab -e set graphical message , used system wide crontab /etc/crontab define shutdown of machine - in case, using , defining "xhost local:paulo", didn't , neither setting "export no_at_bridge=1" - worked was: - list item

1- acessing crontab -e in terminal/console

1.1. */30 * * * * display=:0 /home/paulo/aviso.sh

2- acessing sistem wide crontab sudo gedit /etc/crontab

2.1. */30 * * * * root shutdown -r +2

if acess crontab -e invited choose between diferent text-editors; chose nano; after pasting/writing text need use control + x save text , hit enter.

so that`s it. thanks. solved.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User