1 | #!/bin/bash |
---|
2 | # |
---|
3 | # Cron to keep track of the consumption and data volume |
---|
4 | # for GENCMIP6 project. |
---|
5 | # To be executed every day at 6am |
---|
6 | # ====================================================================== |
---|
7 | |
---|
8 | # Initialize module command |
---|
9 | # ========================= |
---|
10 | if [ -f /etc/bashrc ] ; then |
---|
11 | . /etc/bashrc |
---|
12 | fi |
---|
13 | |
---|
14 | # Load python |
---|
15 | # =========== |
---|
16 | # python/2.7.3 is the default, but it comes with matplotlib 1.2, |
---|
17 | # which is too old (no context manager for PdfPages) |
---|
18 | module load python/2.7.8 |
---|
19 | |
---|
20 | # Go to root directory |
---|
21 | # ==================== |
---|
22 | ROOT_DIR=$( dirname $0 ) |
---|
23 | cd ${ROOT_DIR} |
---|
24 | |
---|
25 | # Main script to get data |
---|
26 | # ======================= |
---|
27 | script="conso_gencmip6" |
---|
28 | printf "${script}\n" |
---|
29 | echo "--------------------" |
---|
30 | bin/${script}.py -v |
---|
31 | rc=$? |
---|
32 | if [ ${rc} -ne 0 ] ; then |
---|
33 | echo "${script} terminated abnormally" |
---|
34 | exit |
---|
35 | else |
---|
36 | echo "${script} OK" |
---|
37 | fi |
---|
38 | |
---|
39 | # Plot daily consumption |
---|
40 | # ====================== |
---|
41 | # -f : plot the whole period of the project |
---|
42 | # -d : copy plot on dods |
---|
43 | # -v : verbose mode |
---|
44 | script="plot_bilan" |
---|
45 | printf "\n${script}\n" |
---|
46 | echo "--------------------" |
---|
47 | bin/${script}.py -fv |
---|
48 | rc=$? |
---|
49 | if [ ${rc} -ne 0 ] ; then |
---|
50 | echo "${script} terminated abnormally" |
---|
51 | else |
---|
52 | echo "${script} OK" |
---|
53 | fi |
---|
54 | |
---|
55 | script="plot_bilan_jobs" |
---|
56 | printf "\n${script}\n" |
---|
57 | echo "--------------------" |
---|
58 | bin/${script}.py -fv |
---|
59 | rc=$? |
---|
60 | if [ ${rc} -ne 0 ] ; then |
---|
61 | echo "${script} terminated abnormally" |
---|
62 | else |
---|
63 | echo "${script} OK" |
---|
64 | fi |
---|
65 | |
---|
66 | script="plot_jobs_daily" |
---|
67 | printf "\n${script}\n" |
---|
68 | echo "--------------------" |
---|
69 | bin/${script}.py -fv |
---|
70 | rc=$? |
---|
71 | if [ ${rc} -ne 0 ] ; then |
---|
72 | echo "${script} terminated abnormally" |
---|
73 | else |
---|
74 | echo "${script} OK" |
---|
75 | fi |
---|
76 | |
---|
77 | script="plot_login" |
---|
78 | printf "\n${script}\n" |
---|
79 | echo "--------------------" |
---|
80 | bin/${script}.py -v |
---|
81 | rc=$? |
---|
82 | if [ ${rc} -ne 0 ] ; then |
---|
83 | echo "${script} terminated abnormally" |
---|
84 | else |
---|
85 | echo "${script} OK" |
---|
86 | fi |
---|
87 | |
---|
88 | script="plot_store" |
---|
89 | printf "\n${script}\n" |
---|
90 | echo "--------------------" |
---|
91 | # Last STORE file produced |
---|
92 | data_file="OUT_CONSO_STORE" |
---|
93 | OUTDIR="${HOME}/ConsoGENCMIP6/output" |
---|
94 | # Directories in last file |
---|
95 | dirlist=$( gawk '{if ($4 != "dirname") print $4}' ${OUTDIR}/${data_file} ) |
---|
96 | # Where to find the saved files |
---|
97 | SAVEDIR="${WORKDIR}/ConsoGENCMIP6/data" |
---|
98 | # Previous STORE files |
---|
99 | filelist=$( ls ${SAVEDIR}/${data_file}_* ) |
---|
100 | fileout="${data_file}_INIT" |
---|
101 | echo "date login dirsize dirname" > ${OUTDIR}/${fileout} |
---|
102 | for dir in ${dirlist} ; do |
---|
103 | grep -h "$dir\$" ${filelist} | head -1 |
---|
104 | grep -h "$dir\$" ${filelist} | head -1 >> ${OUTDIR}/${fileout} |
---|
105 | done |
---|
106 | |
---|
107 | bin/${script}.py -v |
---|
108 | rc=$? |
---|
109 | if [ ${rc} -ne 0 ] ; then |
---|
110 | echo "${script} terminated abnormally" |
---|
111 | else |
---|
112 | echo "${script} OK" |
---|
113 | fi |
---|
114 | |
---|
115 | |
---|
116 | # Copy web files to ciclad |
---|
117 | # ======================== |
---|
118 | echo "=> Copy web files to ciclad" |
---|
119 | echo "===========================" |
---|
120 | rsync -var ${ROOT_DIR}/web/* igcmg@ciclad.ipsl.jussieu.fr:dods/ConsoGENCMIP6 |
---|
121 | |
---|
122 | |
---|
123 | printf "\nEnd of script OK\n" |
---|
124 | |
---|