Gambas program will not start from cron [solved]
Posted
#1
(In Topic #1405)
Trainee
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?
Posted
Regular

Code (gambas)
- /pathto/gbx3 /home/prl/statusmail.gambas >> /home/prl/logfile
b
Posted
Trainee
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.
Posted
Guru

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>
Posted
Trainee
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!
1 guest and 0 members have just viewed this.


