lundi 21 février 2011

conditions dans crontab


[adx-db01]$ cat test.sh
#!/bin/bash


#[ $(TZ=GMT-48 date +%d) -eq "18" ] && echo "ok" || eco 'pas ok'

SVR=$(TZ=GMT-48 date +%d)

ADXDB01=[ $(TZ=GMT-48 date +%d) -eq "18" ]

[ $ADXDB01 ] && echo "ok" || echo "pas ok"


* * 8-14 * * if [ `date +\%a` = "Sat" ]; then /apps/scripts/test.ksh; fi >> testlog

These will not work:-
* * 8-14 * 0 if [ `date +\%a` = "Sat" ]; then /apps/scripts/test.ksh; fi >> testlog
or
* * 8-14 * 0 /apps/scripts/test.ksh >> testlog




---

@Don
@SathiyaMoorthy

To execute a script on some days of a week and only between some days of a month you can do it this way:

# Nur am Montag (1) oder am Donnerstag (4)
10 19 2-27 * * if [ "$(date +\%u)" = "1" ] || [ "$(date +\%u)" = "4" ] ; then ./yourscript.sh ; fi

This here will not work !!!
10 19 2-27 * 1,4
--

35 * * * * /usr/bin/test -x /usr/local/cpanel/bin/tail-check && /usr/local/cpanel/bin/tail-check