Cron job running a bash script (which runs a script in python) behaving different from when executed manually
-
Hi. I have a python script that plots two different graphs and that needs to be run daily to update these graphs on a site
The data that is used by this script is in a given HDF format directorship
I created a Bash script that copies the data from this directorship, converts to Netcdf, paste into another directorship, runs this script in python and updates the graphs 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 running the bash script: The data is being copied, converted and pasted. ..the script in python is running and plotting the graphite soh that one of them, is coming with problem
In one of the graphite (which plots the orbit of a satellite), I need to put the initial and final time of data bracket
Something like that:
Start: 00:00:38 UTC
End: 01:29:57 UTC
SOH THAT ... when run by crontab, what is being plotted eh this:
Start: 0 UTC
End: 4 UTC
If I roll manually, it works perfectly, and plots the hours the right way
This is the part of my script in python 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')
This is 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}* update@140.203.204.132:/home/www/html/rt/PICS/${year}/
rsync -u -z -v -e "ssh -p 8222" /mnt/raid/CALIPSO/PICS/${previous_year}* update@140.203.204.132:/home/www/html/rt/PICS/${previous_year}/
And that's the way I programmed the crontab to run:
0 9 * * * /mnt/raid/CALIPSO/SCRIPTS/copy_convert_plot_update_twodaysago.sh
Does anyone have any idea what might be happening?
-
As you did not put if this using privileged user or not my suggestion would be to aim at the cron with which user you want your .py surround. * * * update_user /var/www/web/includes/crontab/queue_process.php > /var/www/web/includes/crontab/queue. log 2 >1