I have written a script using GNUPLOT . It works great when i run manually but when i put in crontab it give me library file missing. Any inputs are highly appreciated.
#!/local/tools/monitoring/gnuplot-new/bin/gnuplot
set terminal png size 1024,768
set output 'graph.png'
set title "System monitoring"
set xlabel "time"
set key outside bottom
set ylabel "%"
set ytics format '%s%c'
set yrange [1:1024**2]
set autoscale
set grid
set xdata time
set format x "%H:%M"
set timefmt "%d-%m %H:%M:%S"
set ylabel "GB"
plot "testmemory.csv" using 1:3 title "used" with lines,\
"testmemory.csv" using 1:4 title "buffered" with lines,\
"testmemory.csv" using 1:5 title "cached" with lines,\
"testmemory.csv" using 1:6 title "free" with lines
When run through crontab this gives me below error.
gnuplot: error while loading shared libraries: libwx_gtk2u_xrc-3.0.so.0: cannot open shared object file: No such file
or directory
OK. I see you are using tcsh.
If you can locate libwx_gtk2u_xrc-3.0.so.0 on your system (as Corona688 posted earlier), I was thinking you could add the path to that file in the PATH env variable, and then export it from within your script. If you can't locate that lib file, then you have other issues with gnuplot itself or your distro.
Have you tested running your script directly ( not using cron )?
Gnuplot doesnt have a lib directory. This lib file is located with other application called wx-widgets . That was also exported under .cshrc file . Gnuplot uses wx-widgets as well.
OK. Then it's a cron issue.
It's not about libwx_gtk2u_xrc-3.0.so belonging to gnuplot. It's a library shared by lots of applications like you said.
So I say again...help cron find the shared library file. Cron runs in a very minimal
environment and doesn't know where to search for files needed by other applications. Gnuplot will be running as a child process of Cron and will be running in Cron's 'blind' environment.
You'll have to edit your script and see if this works or not.
On my system this file is in /usr/lib64
#!/local/tools/monitoring/gnuplot-new/bin/gnuplot
export PATH="$PATH:/usr/lib?" ## the directory where you found libwx_gtk2u_xrc-3.0.so.
set terminal png size 1024,768
set output 'graph.png'
...
...
/local/tools/monitoring/gnuplot-new/bin/gnuplot: error while loading shared libraries: libwx_gtk2u_xrc-3.0.
so.0: cannot open shared object file: No such file or directory
This just saves specifying a full path for you data files eg:
plot "/home/ajayram/sar_logs/29122014/datafile" using 1:3 title "used" with lines,\
"/home/ajayram/sar_logs/29122014/datafile" using 1:4 title "buffered" with lines,\
"/home/ajayram/sar_logs/29122014/datafile" using 1:5 title "cached" with lines,\
"/home/ajayram/sar_logs/29122014/datafile" using 1:6 title "free" with lines
Can become:
set loadpath '/home/ajayram/sar_logs/29122014'
plot "datafile" using 1:3 title "used" with lines,\
"datafile" using 1:4 title "buffered" with lines,\
"datafile" using 1:5 title "cached" with lines,\
"datafile" using 1:6 title "free" with lines