0

I want to start a python tkinter app at the start of the sesion, I add the next lines to my user and root crontab

@reboot python3 /home/alvaro/Desktop/python/good.py

But when I reboot the app doesn't start

This is the output of the cron status
  ● cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2021-04-19 10:35:07 CEST; 1min 46s ago
       Docs: man:cron(8)
   Main PID: 622 (cron)
      Tasks: 1 (limit: 9484)
     Memory: 19.6M
     CGroup: /system.slice/cron.service
             └─622 /usr/sbin/cron -f

abr 19 10:35:07 alvaro-VirtualBox cron[622]: (CRON) INFO (pidfile fd = 3)
abr 19 10:35:07 alvaro-VirtualBox cron[622]: (CRON) INFO (Running @reboot jobs)
abr 19 10:35:07 alvaro-VirtualBox CRON[631]: pam_unix(cron:session): session opened for user root by (uid=0)
abr 19 10:35:07 alvaro-VirtualBox CRON[636]: (root) CMD (python3 /home/alvaro/Desktop/python/good.py)
abr 19 10:35:07 alvaro-VirtualBox CRON[632]: pam_unix(cron:session): session opened for user alvaro by (uid=0)
abr 19 10:35:07 alvaro-VirtualBox CRON[693]: (alvaro) CMD (python3 /home/alvaro/Desktop/python/good.py)
abr 19 10:35:09 alvaro-VirtualBox CRON[631]: (CRON) info (No MTA installed, discarding output)
abr 19 10:35:09 alvaro-VirtualBox CRON[631]: pam_unix(cron:session): session closed for user root
abr 19 10:35:09 alvaro-VirtualBox CRON[632]: (CRON) info (No MTA installed, discarding output)
abr 19 10:35:09 alvaro-VirtualBox CRON[632]: pam_unix(cron:session): session closed for user alvaro
8
  • 2
    Programs running from cron don't have a graphic environment so they will fail if they try to use graphics. What did you expect the program to do ?
    – Soren A
    Apr 19, 2021 at 8:51
  • Just start the interface at the beginning, I also tried with a script that runs the program but does nothing, is it possible to start the graphical interface of the program from the beginning?
    – mourazo
    Apr 19, 2021 at 8:58
  • 2
    As said, cron has no graphical environment set up. Also you are not logged in when it try to run at reboot, so there are no screen/graphical session anyway. Have you tried adding the program (or script) to "Startup Applications" ("Startup Applications Preference") ? That should start the program at login.
    – Soren A
    Apr 19, 2021 at 9:04
  • 2
    I can't help you with the setup, but I would suggest getting the app to start via Startup Applications and then setting Auto Login. Or try searching for "Ubuntu kiosk setup" .. you will find something like this: ubuntu.com/tutorials/secure-ubuntu-kiosk#1-overview
    – Soren A
    Apr 19, 2021 at 9:26
  • 1
    As mentioned you can gooogle search for "Ubuntu Kiosk". Here is one example result: linuxquestions.org/questions/ubuntu-63/… Apr 19, 2021 at 10:57

1 Answer 1

4

Cron don't have a graphical environment so you can't run GUI programs from there. Also when running a program at reboot you are not logged in, so there are no graphical session available.

Add your program to "Startup Applications" ("Startup Applications Preference") to make it start at login. Eventually enable "Auto login" to avoid giving username and password.

Also you can search for Ubuntu kiosk setup" to find information on setting a KIOSK solution - that is a setup where an application starts automatically at boot, without giving the users access to the Desktop .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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