running batch jobs via Linux cron

Get help for specific problems
JohnHaggerty
Posts: 7
Joined: 4 Jun 2019

Post by JohnHaggerty • 14 Aug 2019, 14:02

Hi folks,

I have a script which runs various FFS batch jobs without a problem when initiated from a Linux Mint Terminal window. However, when initiated by cron all the FFS batch jobs fail -
Error: Unable to initialize GTK+, is DISPLAY set properly?
return_code=255

***** Sorted *****
I ran env in Terminal and compared it with running env in the cron job. I then added the following Terminal env variables to the crontab entry:
DISPLAY=:0
GTK_OVERLAY_SCROLLING=1
GTK_MODULES=gail:atk-bridge

Although it's nothing to do with FFS I also got 'No volume for device file' errors when running 'gio mount -d' commands.
Adding the following Terminal env variable to the crontab entry fixed it:
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus

Regards,

John

P.S. I wish I'd searched the Forum on 'cron' rather than 'gtk', then I'd have found out without having to experiment for myself that I only needed the DISPLAY=:0 variable. I've since removed the GTK_ variables with no problems.