📣 An issue occured with the embedded container registry on October 25 2021, between 10:30 and 12:10 (UTC+2). Any persisting issues should be reported to CC-IN2P3 Support. 🐛

Commit 913acf4b authored by Magneville's avatar Magneville
Browse files

recuperation automatique des TLE par crontab, cmv 19/04/2019

parent b96d0cb6
#!/bin/bash
#----------------------------------------------------------
# crontab job: recuperation de TLE de Celestrak
# voir "crontab_TLE.help" pour la mise en place du crontab
#----------------------------------------------------------
#...les TLE chez Celestrak
http='http://www.celestrak.com/NORAD/elements'
#Navigation Satellites
navigation="galileo gps-ops glo-ops beidou nnss sbas"
#Communication Satellites
communic="intelsat ses iridium iridium-NEXT orbcomm globalstar amateur x-comm other-comm gorizont raduga molniya stations"
#Rescue Satellites
rescue="sarsat"
#...les TLE que l'on veut telecharger
todo=( ${navigation[*]} ${communic[*]} ${rescue[*]} )
#...le repertoire racine (A MODIFIER)
ROOTREP='/home/manip/Run'
cd ${ROOTREP}
if [ "$?" -ne "0" ] ; then
echo 'ERROR cron_getTLE.sh: unkwon base directory' ${ROOTREP}
exit -1
fi
#
mkdir -p TLE
if [ "$?" -ne "0" ] ; then
echo 'ERROR cron_getTLE.sh: impossible to create directory TLE'
exit -2
fi
cd TLE
if [ "$?" -ne "0" ] ; then
echo 'ERROR cron_getTLE.sh: impossible to cd into directory TLE'
exit -2
fi
#...le repertoire du telechargement
REP_NAME=`date +"%Y%m%d-%H%M%S"`
mkdir -p ${REP_NAME}
if [ "$?" -ne "0" ] ; then
echo 'cron_getTLE.sh: ERROR impossible to create directory' ${REP_NAME}
exit -3
fi
cd ${REP_NAME}
#...le telechargement (en mode "quiet")
for F in ${todo[*]} ; do
wget -q ${http}/${F}.txt
done
nget=$(ls -1 *.txt | wc -l)
#...l'output qui est ecrit dans /var/log/syslog
echo 'cron_getTLE.sh: TLE for date' ${REP_NAME} ':' ${nget} 'files downloaded'
exit 0
-------------------------------------------------------------
-------------------------------------------------------------
------- Recuperation automatique des TLE de Celestrak -------
-------------------------------------------------------------
-------------------------------------------------------------
-----
1-/ Script de recuperation des TLE
-----
#- Mettez le script "cron_getTLE.sh" dans un repertoire facilement accessible (~/bin ou autre)
Le fichier cron_getTLE.sh est dans ce repository
#- CHANGER LE REPERTOIRE RACINE "ROOTREP" pour votre environnement
ROOTREP='/home/manip/Run' <- A MODIFIER
-----
2-/ Creation d'un crontab (utilisateur, pas de modif des crontab systeme)
-----
#- Recuperer votre crontab file perso :
crontab -l > my-crontab
Si vous n'en avez pas, la commande vous en fabriquera un.
(((Pour info:
La crontab file personnelle est dans /var/spool/cron/crontabs/"USER"
!!! NE PAS EDITER CE FICHIER MANUELLEMENT !!!
)))
#- Modifier votre crontab file perso "my-crontab" en ajoutant a la fin:
............................................................................
#pas d'envoi de mail a l'utilisateur
MAILTO=""
#PAON4 get_TLE: tous les lundi
* * * * 1 /home/cmv/bin/cron_getTLE.sh 2>&1 | /usr/bin/logger -t PAON4_TLE
............................................................................
A faire:
. Dans la derniere ligne, renseignez le chemin COMPLET. Mettez le votre !
Ici: "/home/cmv/bin/cron_getTLE.sh"
^^^^^^^^^^^^^^
Un exemple de crontab file dans ce repository: "my-crontab_getTLE"
Explications:
. "2>&1" : redirige stderr dans stdout
. "/usr/bin/logger" : redirige stdout dans /var/log/syslog
. "-t PAON4_TLE" : est un tag qui facilite l'identification dans syslog
#- Installer la crontab file modifiee
crontab my-crontab
ATTENTION: si vous avez un crontab personnel, le sauvegarder avant toute operation
*** Ceci NE concerne PAS les crontab system qui ne seront pas impactes ***
#- Attendez lundi prochain =)
Pour identifier les problemes ou voir ce qui a ete fait, regardez dans /var/log/syslog
> grep PAON4_TLE /var/log/syslog
Apr 19 22:57:01 dphppcc226 CRON[16545]: (cmv) CMD (/home/cmv/bin/cron_getTLE.sh 2>&1 | /usr/bin/logger -t PAON4_TLE)
Apr 19 22:57:07 dphppcc226 PAON4_TLE: cron_getTLE.sh: TLE for date 20190419-225701 : 20 files downloaded
^^^^^^^^^^^^^^^^^^^
Si la connexion internet est coupee, ou si il y a un pb (site web inaccessible)
le repertoire "date" sera vide :
> grep PAON4_TLE /var/log/syslog
Apr 19 22:54:01 dphppcc226 CRON[16256]: (cmv) CMD (/home/cmv/bin/cron_getTLE.sh 2>&1 | /usr/bin/logger -t PAON4_TLE)
Apr 19 22:54:01 dphppcc226 PAON4_TLE: ls: cannot access '*.txt': No such file or directory
Apr 19 22:54:01 dphppcc226 PAON4_TLE: cron_getTLE.sh: TLE for date 20190419-225401 : 0 files downloaded
^^^^^^^^^^^^^^^^^^
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
#pas d'envoi de mail a l'utilisateur
MAILTO=""
#
# m h dom mon dow command
#
#PAON4 get_TLE: tous les lundi
* * * * 1 /home/cmv/bin/cron_getTLE.sh 2>&1 | /usr/bin/logger -t PAON4_TLE
###PAON4 get_TLE: toutes les 3 mn (ONLY FOR TEST)
### */3 * * * * /home/cmv/bin/cron_getTLE.sh 2>&1 | /usr/bin/logger -t PAON4_TLE
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment