Cerin Cerin - 6 months ago 79
Linux Question

ssconvert from www-data cron on a headless server fails with various errors

I'm attempting to run the Gnumeric utility

ssconvert
from a crontab as part of a job that processes spreadsheet files. It runs perfectly from my Desktop. It even runs perfectly on my headless server, but when I try to run it from cron on my headless server, it returns the error:


(ssconvert:27858): GLib-GObject-WARNING **: invalid (NULL) pointer instance

(ssconvert:27858): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

(ssconvert:27858): Gtk-CRITICAL **: Unable to create user data directory '/var/www/.local/share' for storing the recently used files list: Permission denied ** Gtk:ERROR:/build/buildd/gtk+3.0-3.10.8/./gtk/gtkrecentmanager.c:617:gtk_recent_manager_set_filename: assertion failed: (priv->filename != NULL) Aborted (core dumped) No valid data found.


I'm assuming this error is the result of some permission issue with cron. The cron job runs under
www-data
role on Ubuntu. However, again, if I try and simulate this with:

sudo -u www-data bash -c "myscript.sh"


it runs fine. And myscript.sh makes simple calls like:

ssconvert oldfile.xls newfile.csv


My www-data crontab is dead simple and looks like:

PATH=/usr/sbin:/usr/bin:/sbin:/bin
SHELL=/bin/bash
* * * * * bash -c "myscript.sh"


What am I doing wrong? Why can I use the
www-data
user to run the script but cron can't?

Answer

Unable to create user data directory '/var/www/.local/share' for storing the recently used files list: Permission denied

This looks like the relevant part of the error message. I would assume that (1) you can reproduce the error if you run ssconvert in /var/www manually; and (2) if you create this directory with adequate permissions, that will resolve the issue.

I further assume it already exists in the directory where you managed to run it successfully.