drupal-crons.sh

Printer-friendly versionPrinter-friendly version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
 
#
# Drupal sites cronjob runner. Useful to be put into crontab.
# samu 2009-12-06
#
 
## --- Configuration ---
CONF_SITES="/usr/local/etc/drupal-sites" # sites list
CONF_LOGDIR="/var/log/drupal-cron" # logs dir
## --- End Config ---
 
# load sites list, stripping lines that are empty or starting by #
SITES="$(cat "$CONF_SITES" |grep -ve "^$\|^[^A-Za-z0-9]*#")"
 
# create log directory if not exists
if [ ! -e "$CONF_LOGDIR" ] ; then
  echo " * Creating log directory: $CONF_LOGDIR"
  mkdir -p "$CONF_LOGDIR"
fi
 
# prepare logfile name
LOGFILE="$CONF_LOGDIR/drupal-cron_$( date "+%Y-%m-%d" ).log"
 
# Run all cronjobs
echo "--- Drupal Cronjobs `date "+%Y-%m-%d %H:%M"` -------------------------------------------" | tee -a $LOGFILE
for site in $SITES; do
#   wget -S -O - http://drupaltest.drupal.local/cron.php 2>&1 |grep "  HTTP/"|cut -d' ' -f4,5
  printf "%-50s" "  * Cron for $site ... " | tee -a $LOGFILE
  #echo -n "  * Cron for $site ... " | tee -a $LOGFILE
  wget -S -O - -T 30 "http://${site}/cron.php" 2>&1 |
    grep "  HTTP/" |
    tail -n1 |
    sed 's/^ *HTTP[^ ]* \(.*\)/\1/' |
    tee -a $LOGFILE
done
 
echo "Done. Logfile on $LOGFILE"

Who Am I?

~redShadow~ A.K.A. Samuele Santi is an Italian Open Source developer, currently working as a freelance developer, mainly in the web applications sector. Favourite programming languages: PHP and, of course, Python!

C++ (2) apt (1) Drupal (21) aircrack (1) bash (11) awstats (3) cartoons (1) citroen (1) contact manager (1) apache (1) address book (2) database (3) cars (1) algorythms (1) documentation (2) blender (3) arduino (1) archive (1) curl (1) Drupal Forms (1) blogroll (7) backup (3) doku (1) debug (1) como lake rovers (1) cryptography (1) e-mail (2) aoe (1) dmcrypt (1) debian (1) camera mia (1) caos (1) audio (1) circuits (1) 3d (3) 2v (1) code (3) alcool (1) development (11) cocktails (1)