OpenOffice automatic open with Cron

Issues with installing under all GNU/Linux Distributions
Post Reply
iammenotyou
Posts: 2
Joined: Thu Apr 14, 2016 7:00 pm

OpenOffice automatic open with Cron

Post 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.
LibreOffice 5.1.2.2
Ubuntu 16.04
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: OpenOffice automatic open with Cron

Post 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.
AOO4/LO5 • Linux • Fedora 23
iammenotyou
Posts: 2
Joined: Thu Apr 14, 2016 7:00 pm

Re: OpenOffice automatic open with Cron

Post 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)?
LibreOffice 5.1.2.2
Ubuntu 16.04
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: OpenOffice automatic open with Cron

Post by acknak »

You're already beyond what I know about it. Sorry my suggestion wasn't more useful.
AOO4/LO5 • Linux • Fedora 23
User avatar
RoryOF
Moderator
Posts: 34613
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OpenOffice automatic open with Cron

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply