Using gio mount in a bash script that is started periodically by cronjob

273 views Asked by At

I have bash script in which via gio mount a webdav share is mounted. The script works perfectly. However, when I call the script via chronjob I get errors. As I have read on the internet, it is because the cronjob not all environment variants are available.
As described on Lorenzo's page, various variables must be set.
https://lbolla.info/gio-in-cronjob.html

It is not clear to me how and where I have to insert the example of Lorenzo. I am using Debian. In the example of Lorenzo is something from Ubuntu, this I must certainly adapt.

1

There are 1 answers

0
qbicsky On

It is an old thread, but I see there is now answer. You can't use environmental variables from Ubuntu on Debian. Going after Lorenzo's solution for Ubuntu, you should check those vars on your OS, so simply just do on your command line:

echo $XDG_DATA_DIRS
# possible output: /usr/share/gnome:/usr/local/share/:/usr/share/
echo $DBUS_SESSION_BUS_ADDRESS
# possible output: unix:path=/run/user/1000/bus

And then, simply put those vars at the beginning of your script ie. just under your bash interpreter declaration.

edit: You can also place env vars in the crontab itself, before cron definitions.