J'ai un TS 859 avec le firmware suivant : 3.4.4 0718T
Je voudrais ajouter un script dans mon crontab, et biensur que celui-ci soit toujours présent après chaque Reboot.
Mais là je sèche.
Tout d'abord, j'utilise la méthode de l'autorun, pour lancer un script placé sur un de mes DDur :
mount -t ext2 /dev/sdx6 /tmp/config vi /tmp/config/autorun.sh #!/bin/sh /share/HDA_DATA/Script/autorunmaster.sh
Ca ca fonctionne.
Dans ce fichier autorunmaster je lance un script : /share/HDA_DATA/Script/crontab.sh que voici :
#!/bin/sh # location: /share/HDA_DATA/Script/crontab.sh # script name: crontab script # purpose: add entries to the crontab, which will survive a QNAP reboot # designed for Qnap TS-859 tmpfile=/tmp/crontab.tmp # read crontab and remove custom entries (usually not there since after a reboot # QNAP restores to default crontab: crontab -l | grep -vi "dynhost" | grep -vi "custom1.sh" | grep -vi "custom2.sh" > $tmpfile # add custom entries to crontab echo "*/2 * * * * /share/HDA_DATA/Script/DynHost/dynhost" >> $tmpfile #echo "1 4 * * * /share/HDA_DATA/scripts/custom1.sh" >> $tmpfile #echo "40 5 * * * /share/HDA_DATA/scripts/custom2.sh" >> $tmpfile #load crontab from file crontab $tmpfile # remove temporary file rm $tmpfile # restart crontab /etc/init.d/crond.sh restart
Si je lance le script autorunmaster.sh, le Crontab est bien mis a jour.
Mais pendant un redémarrage le NAS exécute le script autorun un peu trop tôt on dirait, puisque le crontab est réécrit par la suite.
Si je lance mon crond.sh en tache de fond et si j'ajoute une tempo Sleep pour la mise a jour du Crontab, ca marche mais cette solution n'est pas terrible je trouve.
Lancement du crond.sh en tache de fond :
/share/HDA_DATA/Script/crontab.sh &
Temporisation dans le script crond.sh:
sleep 60
De plus si je modifie un paramètre (qui ajouterais une ligne dans le cron) via la page de config du Qnap, les modifications du script sont alors perdu.
Est-ce qu'il existe un autre moyen plus fiable ?
















