Page 1 of 1

OpenOffice automatic open with Cron

Posted: Thu Apr 14, 2016 7:09 pm
by iammenotyou
I have an ubuntu installation (fresh) with a fresh install of OpenOffice.

I've created a spreadsheet in Calc that does some processing every evening.

So I'm trying to open the file every evening at 12:30

So I created a script that contains the following:
soffice --calc --norestore /home/user/Dropbox/Calculator/Updater.ods

and i opened crontab
sudo crontab -e
and added the following lines
30 01 * * * /home/user/Dropbox/updaterscript.sh
30 00 * * * export DISPLAY=:0 && /home/user/Dropbox/updaterscript.sh

If i go into the directory and run the scipt, Calc opens and does exactly what it's supposed to do.

When cron time passes nothing happens for either activity. (Also tried as user as opposed to as root)

I should note, security is not an issue.

Re: OpenOffice automatic open with Cron

Posted: Thu Apr 14, 2016 8:09 pm
by acknak
In my experience, running GUI software from cron is problematic because they aren't running in a normal, logged-in and configured session. That was a long time ago; maybe it's different now.

I would suggest looking online for examples of command-lines/options for running OO without user interaction. I believe one option for this is --headless.

Re: OpenOffice automatic open with Cron

Posted: Thu Apr 14, 2016 8:52 pm
by iammenotyou
ok, so it appears, that with the crontab of
30 00 * * * export DISPLAY=:0 && /home/user/Dropbox/updaterscript.sh

it actually called the script of:
soffice --calc --norestore /home/user/Dropbox/Calculator/Updater.ods

when running the script manually it opens OO and does what it needs to do. The after a 5 minute wait, the autostarted macro saves and exits.

When using cron however, it doesn't open on the screen, just running ps -ef i can see the process is running. The problem is since it opens this way, it doesn't do any of the updates/save/exit.

I should also add that adding --headless to the script caused it to immediately quit after opening. Manually it runs, just not sure if it does anything.

Is there perhaps another tool that I use to schedule running the script, but one that would open the UI as well (like when the script is run manually)?

Re: OpenOffice automatic open with Cron

Posted: Thu Apr 14, 2016 9:42 pm
by acknak
You're already beyond what I know about it. Sorry my suggestion wasn't more useful.

Re: OpenOffice automatic open with Cron

Posted: Thu Apr 14, 2016 9:45 pm
by RoryOF
Try using the cron job to change to the directory, then run the task, rather than run the task from the root using a path.