Running Compiled App on RasPi with Cron

Trying to get cron wirking to run a Xojo desktop app at regular intervals. Currently it is saved to desktop and using crontab (either user or sudo) with full path to executable (set as executable) does nothing.

I think it is related to cron not having access to desktop for a particular user.

Tried saving in bin/ or etc/cron(hourly) but that results in an access denied error.

Where should the app be saved fir it to be executed by cron ?

Thanks,
Steve

cron is more for console apps without gui, or to execute scripts.
Xojo desktop app need a logged in user with desktop.

maybe you can auto start a desktop app in an user context with desktop and let it run 24/7 and using a timer to do things.

example for permissions

sudo chmod -R ugo+rwx /home/pi

-R = Recursiv
u = users
g = groups
o = others
r = read
w = write
x= execute
+ add permissions
- remove permissions
sudo chmod -R 777 /etc/xdg/autostart
groups pi
sudo adduser anyuser groupname
sudo deluser anyuser groupname
1 Like

Thanks. Pretty sure I have done the above via right click properties.

Re gui - no issue tyrning it into a console app if that’s the problem

Norman thinks that because cron runs without being attached to a UI session that you may have some problems running a Desktop app.

I might suggest starting with a hello world console app scheduled to run via cron just to rule out the UI as a problem.

1 Like

This seems potentially relevant:

https://forums.raspberrypi.com/viewtopic.php?t=163752

It looks like you might have to give Rasbpian (sp?) a “hint” for it to understand you want to use the gui.

From the linked article:

The code

sudo su -c "env DISPLAY=:0.0 /usr/bin/java -jar $path$file &" $user

is not working as expected, but I finally found out : I added

Code: Select all

export XAUTHORITY=/home/pi/.Xauthority
export DISPLAY=:0.0
java -jar $path$file &

in the Script launched by cron, and It WORKS !

1 Like