Hi .. I have a python script that plots two different graphs and that needs to be run daily to update these graphs on a website
The data that is used by this script, is in a certain directory in HDF format
I created a Bash script that copies the data from this directory, converts it to Netcdf, paste it into another directory, runs that script in python and updates the graphics on the site
As I said, I need these graphs to be updated daily on the site, so I programmed this bash script to be run daily by crontab
The crontab is actually executing the bash script: The data is being copied, converted and pasted ... the python script is running and plotting the graphics soh that one of them is coming with problem
In one of the graphs (which plots the orbit of a satellite), I need to put the start and end time of data collation
Something like this:
Start: 00:00:38 UTC
End: 01:29:57 UTC
SOH WHEN ... when run by crontab, what is being plotted is this:
Start: 0 UTC
End: 4 UTC
If I run manually, it works perfectly, and it plots the hours the right way
This is the part of my python script that is plotting the hours:
def cal_protime2dt(time):
d = int(time % 100)
m = int((time-d) % 10000)
y = int(time-m-d)
return dt.datetime(2000 + y//10000, m//100, d) + dt.timedelta(time % 1)
dates = [cal_protime2dt(time[i]) for i in np.arange(len(time))]
datestr = [i.strftime('%H:%M:%S') for i in dates]
t1=str(datestr[0])
t2=str(datestr[-1])
x, y = m(longitude[0], latitude[0])
m.plot(x, y, marker='D', color='m', markersize=2.1)
plt.text(-95,94.5, 'Start: {:} UTC \n\n\n '.format(t1), fontsize=5.55, color='m', ha='right',va='center')#, bbox=dict(facecolor='w', alpha=0.2))
z, w = m(longitude[-1], latitude[-1])
m.plot(z, w, marker='D', color='b', markersize=2.1)
plt.text(-97, 94.5, ' End: {:} UTC '.format(t2), fontsize=5.55, color='b',ha='right',va='center')
That's my bash script:
#!/bin/bash
ontem=$(date --date="2 days ago" +"%Y-%m-%d");
date=$ontem
year='date +"%Y"'
previous_year='date +"%Y" -d "-1 year"'
h4=/mnt/raid/CALIPSO/SCRIPTS/
dir=/mnt/raid/CALIPSO/DATA/NETCDF_TEMP/
cd /mnt/raid/CALIPSO/DATA/L1.5/2017/
cp CAL_LID_L15_Exp-Beta-V3-40.${date}T*.hdf /mnt/raid/CALIPSO/DATA/NETCDF_TEMP
for i in ${dir}*.hdf; do ${h4}h4tonccf_nc4 $i; done
python ${h4}CalipsoLatLonTimeLoop_TimTrack.py
rsync -u -z -v -e "ssh -p 8222" /mnt/raid/CALIPSO/PICS/${year}* [email protected]:/home/www/html/rt/PICS/${year}/
rsync -u -z -v -e "ssh -p 8222" /mnt/raid/CALIPSO/PICS/${previous_year}* [email protected]:/home/www/html/rt/PICS/${previous_year}/
And this is the way I programmed crontab to run:
0 9 * * * /mnt/raid/CALIPSO/SCRIPTS/copy_convert_plot_update_twodaysago.sh
Does anyone have any idea what might be happening?