-1

Noob question.

I have an executable file saved here:

/home/pi/auroramon-1.07/src/auroramon

When I enter /home/pi/auroramon-1.07/src/auroramon in the command line the program runs.

I created a crontab to execute the program at startup by doing the following:

crontab -e

and added:

@reboot /home/pi/auroramon-1.07/src/auroramon

on rebooting, the program doesn't start

When I run:

$ sudo systemctl status cron.service

I get:

● cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-09-16 16:24:59 BST; 4min 41s ago
       Docs: man:cron(8)
   Main PID: 351 (cron)
      Tasks: 1 (limit: 3720)
        CPU: 260ms
     CGroup: /system.slice/cron.service
             └─351 /usr/sbin/cron -f

Sep 16 16:24:59 raspberrypi systemd[1]: Started Regular background program processing daemon.
Sep 16 16:24:59 raspberrypi cron[351]: (CRON) INFO (pidfile fd = 3)
Sep 16 16:24:59 raspberrypi cron[351]: (CRON) INFO (Running @reboot jobs)
Sep 16 16:24:59 raspberrypi CRON[353]: pam_unix(cron:session): session opened for user ajandco(uid=1000) by (uid=0)
Sep 16 16:24:59 raspberrypi CRON[381]: (ajandco) CMD (/home/pi/auroramon-1.07/src/auroramon)
Sep 16 16:25:01 raspberrypi CRON[353]: pam_unix(cron:session): session closed for user ajandco

which I think is telling me the cron service was running, it executed the necessary command to start the program then closed the cron session.

Any idea what I'm doing wrong / why the program won't start on reboot?

Romeo Ninov
  • 3,195
  • 2
  • 13
  • 16
ajl
  • 1
  • 1
    Does this answer your question? [Why is my crontab not working, and how can I troubleshoot it?](https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it) – user9517 Sep 20 '22 at 05:30
  • The duplicate will almost certainly answer your question. If it does not, it will help you gather information that you canedit into your question to help people help you. – user9517 Sep 20 '22 at 05:32

2 Answers2

0

The cron is executed, but probably it need some environment variables, PATH, etc. What you can do is to create shell script like this:

source /home/pi/.bash_profile
/home/pi/auroramon-1.07/src/auroramon

and change the cron record to point this shell script.

Romeo Ninov
  • 3,195
  • 2
  • 13
  • 16
  • 1
    Almost everycront question can be closed as a dupe of https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it – user9517 Sep 20 '22 at 05:32
  • @user9517, true. Only `cron` about UNIX make the difference :) – Romeo Ninov Sep 20 '22 at 05:36
-1

Thanks Romeo, I had to go in another direction. Apparently cron @reboot can't be used for applications that require desktop GUI as these will attempt to start your programs too early in the boot process. I used sudo nano /etc/xdg/lxsession/LXDE-pi/autostart instead and put the path to the executable there.

ajl
  • 1