Schedule task linux (Cron)

4

How to open a file and shut down the computer with crontab?

Here's my attempt:

30 07 * * * killall qbittorrent (funcionando)
50 07 * * * shutdown -r 1 "Desligando desktop" (não funciona)
30 12 * * * qbittorrent & (não funciona)
55 13 * * * killall qbittorrent (funcioando)
08 20 * * * qbittorrent & (não funciona)
    
asked by anonymous 12.02.2016 / 17:02

1 answer

1

The following commands worked for me (I used firefox instead of qbittorrent because I do not have qbittorrent installed):

$ sudo su

To log in as root and do not change the global crontab table (located at /etc/crontab ).

$ crontab -e

To change the crontab of the root user, with the following entries:

29 * * * * killall firefox
30 * * * * sudo shutdown -r now
35 * * * * su USUARIO -c "DISPLAY=:0.0 firefox"
36 * * * * killall firefox
37 * * * * su USUARIO -c "DISPLAY=:0.0 firefox"

Where USUARIO can be any user on your system with which you wanted to run the command.

I think your command just was not working because $DISPLAY was not set, and the cron program does not understand anything about displaying things on the screen.

    
24.02.2016 / 13:43