ASIC/FPGA Design and Verification Out Source Services
This page presents a script, which is used by this site, to extract,
what pages have been accessed (from apache2 access log).
-
To view the main page of this
work.
This page explains how to run the script from crontab.
-
As said before, the data base for the script, is a root only access
location and therefor this script can not be run from CGI. Instead the
root runs it every hour and creates the
HTML report,
-
To run crontab two files are required: the first one is a script, which
is used to invoke the HTML report. This script, is placed in
/etc/init.d, in my debian machine. The script is simple and is shown
with its documentation here:
#! /bin/sh
#0 * * * * /etc/init.d/aac_day_rep.unx >>/dev/null 2>&1
#* * * * * command to be executed
#I I I I I
#I I I I I
#I I I I I
#I I I I I..... day of week (0 - 6) (0 is Sunday, or use names)
#I I I ........... month (1 - 12)
#I I I............... day of month (1 - 31)
#I I.................... hour (0 - 23)
#.......................... min (0 - 59)
#yearly (or @annually) Run once a year, midnight, Jan. 1st 0 0 1 1 *
#monthly Run once a month, midnight, first of month 0 0 1 * *
#weekly Run once a week, midnight on Sunday 0 0 * * 0
#daily Run once a day, midnight 0 0 * * *
#hourly Run once an hour, beginning of hour 0 * * * *
#reboot Run at startup
- #An example from my debian server
- #Look for and purge old sessions twice hourly (at 9 and 39).
- 09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -ignore_readdir_race -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete
if [ -e "/var/log/apache2/access.log.1" ] ; then
cat /var/log/apache2/access.log.1 /var/log/apache2/access.log > /var/log/apache2/access_tmp.log
perl /home/pini/Home_2/my_web/www_access_day.pl /var/log/apache2/access_tmp.log
rm -f /var/log/apache2/access_tmp.log
else
perl /home/pini/Home_2/my_web/www_access_day.pl /var/log/apache2/access.log
fi
-
To run a backup, not as root (only user kuku has no password scp access),
twice a day:
- su - pini -c "date +%y%m%d_%H%M%S > ~/Home_2/WorkAtHome/pini_work_hour_bak.txt"
- su - pini -c "scp -r /home/pini/Home_2/WorkAtHome/BroadCom pini@192.168.0.179:~/Home_2/WorkAtHome"
And add this line to the crontab start file.
0 10,23 * * * /etc/init.d/work_hour_bak.unx >>/dev/null 2>&1
-
To operate the script a crontab file has to be created. This file has two
entries. One for this script and another for time update. The
latter
is described using ntpdate-debian command.
0 * * * * /etc/init.d/aac_day_rep.unx >>/dev/null 2>&1
0 0 * * * /etc/init.d/init_ntpdate.unx >>/dev/null 2>&1
To enter this entries in crontab, I first erased the former entry by:
crontab -r
and then put the new one by:
crontab CRfile.txt
|