Gambas program will not start from cron [solved]

Post

Posted
Rating:
#1 (In Topic #1405)
Trainee
I have a small gambas program that I want to start from cron in Linux (Mint 19.3).

In crontab I add the following:

0 7 * * 1-5 bash /home/prl/statusmail.bash

The statusmail.bash-script looks like this:

Code

#!/bin/bash

echo ------------------ >> /home/prl/logfile
echo Sending statusmail initiated >> /home/prl/logfile
date >> /home/prl/logfile

wait $\{!}

/home/prl/statusmail.gambas >> /home/prl/logfile

wait $\{!}
echo Statusmail sending finished >> /home/prl/logfile
echo ------------------ >> /home/prl/logfile

The script inserts the rows in the logfile but do not start the gambas program.
If I write /home/prl/statusmail.gambas in cli the program starts.

I suspect that the problem is that cron not handling path in the same way as cli. I have tried to add /usr/lib/gambas3 to etc/environment but no difference.
Do anyone know what gambas-path is missing and were to put it?
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
Just a sheer guess. You may need to explicitly invoke the interpreter:

Code (gambas)

  1. /pathto/gbx3 /home/prl/statusmail.gambas >> /home/prl/logfile
As in Whooe knows what the cron shell environment is.
b

Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
 Thank's for the suggestion thatbruce.

You can invoke the interpreter like
/usr/bin/gbx3 /home/prl/directory_with_your_project

and it works perfect in the terminal but unfortunately not in cron.

If you aren't familiar with Linux or Mac, cron is the way to start tasks at reboot or at a certain time. Every user have it's own crontab file where you put your automated tasks. It's a little like autoexec.bat in windows with the added bonus that you can start things at a certain time, not only when rebooting.

If someone managed to start a gambas program from cron I am very curious how.
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
Try adding this to your script before running the gambas program…

export DISPLAY=:0.0

cron shell environment knows nothing about your gfx session so you must set the DISPLAY environment variable.

<HIGHLIGHT highlight="shell">
#!/bin/bash

echo '——————' >> /home/prl/logfile
echo 'Sending statusmail initiated' >> /home/prl/logfile
date >> /home/prl/logfile

wait ${!}

export DISPLAY=:0.0
gbr3 /home/prl/statusmail.gambas >> /home/prl/logfile

wait ${!}
echo 'Statusmail sending finished' >> /home/prl/logfile
echo '——————' >> /home/prl/logfile
</HIGHLIGHT>
Online now: No Back to the top

Post

Posted
Rating:
#5
Trainee
 Yes, yes, yes!

export DISPLAY=:0.0
gbr3 /home/prl/statusmail.gambas

in the bash file works.

BruceSteers, if you ever travel to Sweden I will buy the beers!
Online now: No Back to the top
1 guest and 0 members have just viewed this.