Ubuntu – Script not running in crontab, file not found

12.04bashcronscripts

I need your help to run a bash script in crontab. As many other posts in askubuntu I'm facing the problem that a script that is properly running in terminal mode does not run in crontab. The error I get is:

/usr/local/rams60/build/fdgrib2/fdgrib2: error while loading shared libraries: libhdf5.so.8: cannot open shared object file: No such file or directory

Cron output also shows TERM environment variable not set.

but of course libhdf5.so.8 exists:

lrwxrwxrwx 1 root root 16 ene 20 12:54 /usr/local/hdf5/lib/libhdf5.so.8 -> libhdf5.so.8.0.1

I found some posts about similar issues like

Why crontab scripts are not working?

https://stackoverflow.com/questions/5064518/shell-script-and-cron-problems?rq=1

Following that posts I set PATH in my script adding both /usr/local/rams60/build/fdgrib2/ and /usr/local/hdf5/lib/

For sure I am missing some simple setting but I can't see where.

Thanks in advance for your help

Best Answer

Try

sudo ln -s /usr/local/hdf5/lib/libhdf5.so.8 /usr/local/lib/
sudo ln -s /usr/local/hdf5/lib/libhdf5.so.8 /usr/lib/

That's the general way for adding something inside PATH.

Also, for check, use

ldd /usr/local/rams60/build/fdgrib2/fdgrib2

This command will show what's missing in your libraries.

Related Question