• CRON – multiple cron jobs on one line (running consecutively, not concurrently)

    This post will (hopefully) remind me in the future how to do something very simple.

    A crontab is normally running one command on each line. EG:

    # m h dom mon dow command
    01 00 * * * /home/cronscripts/vine-warn-when-large-user-profile
    05 00 * * * /home/cronscripts/vine-get-remote-pc-backup.sh
    01 01 * * * /home/cronscripts/vine-samba-users
    01 02 * * * /home/cronscripts/vine-database-backups

    So the above jobs run at 00:01, then 00:05, then 01:01am then 02:01am.

    Instead, I can run these cron tasks one after the other by putting && between each task. EG:

    # m h dom mon dow command
    01 00 * * * /home/cronscripts/vine-warn-when-large-user-profile && /home/cronscripts/vine-get-remote-pc-backup.sh && /home/cronscripts/vine-samba-users && /home/cronscripts/vine-database-backups

    So these jobs start running at 00:01am. When vine-warn-when-large-user-profile finishes, vine-get-remote-pc-backup.sh starts immediately, and so on.

    Why is this useful?

    I have several backup scripts for our linux servers. Each script creates a tar archive of a directory, compresses it, SFTP’s it off site, then deletes the tar archive from the server.

    If the scrips all run at the same time, the server runs out of disk space. I need them to run one after the other. I can’t effectively guess when to start each one. The backup can’t start until after midnight and must be finished by 7am when users are likely to start work again. Some directories can take minutes to archive, compress, send, delete. Others can take 2 or 3 hours. One server also collects backups from a couple of other places, so that script has to complete before others start too.

    Running this scripts concurrently means no useful transfer time is lost and I don’t have to guess the time each script will take to run.


  • cciss-vol-status on Ubuntu didn't work, it was cciss_vol_status

    In the hope I find this post next time I’m trying to monitor a SmartArray drive controller, A fresh install of Ubuntu 10.04, installing package cciss-vol-status didn’t seem to work. I couldn’t even find the file on the system using ‘locate’.

    For some reason, it installed as cciss_vol_status (using underscores instead of hyphens).


  • Bad Bot go away!

    Sigh. Here I am at work on Tuesday morning. List of jobs to do being interrupted by our web server triggering over load alarms. Actually, it’s been doing it for quite a while, but I’ve never sat down to analyse the logs to find what’s happening to trigger the alarm (our gandi.net virtual server is more than powerful enough to cope, so fault finding has been low on my to do list). This morning as I walked to work I saw an overload message arrive in my email. The sun is up, the sky is blue, it’s 8am. It feels a good day to fault find…

    It didn’t take long to find the problem. I used grep to pull out todays log entries from the apache log and put them into a temporary file

    me@server4:/path_to_logs/rkbb.co.uk$ grep ’06/Apr/2010′ apache-log > check.txt

    The bot causing the problem has a user agent of “Mozilla/5.0 (compatible; Purebot/1.1; +http://www.puritysearch.net/)”, going to puritysearch.net I find a ‘search engine’ that doesn’t appear to do anything but display adverts disguised as search results.

    So, how to stop this bot. Nice bots read a file called robots.txt which tells them where they’re allowed to go. Purebot didn’t read the robots.txt so I couldn’t excluded it there.

    My next thought was to use apache to exclude the user agent. After an hour or so of trying I gave up with that (it is possible, I just didn’t figure it out and took the easy for me approach). The site is running Coldfusion (actually BlueDragon) so in the Application.cfm I can check the user agent and stop processing requests from Purebot there.

    <cfset useragenttest = find(“Purebot”,#cgi.http_user_agent#)>

    <cfif useragenttest GT 0 >
      <p>Purebot banned</p>
      <cfabort>
    </cfif>

    The code isn’t my most elegant but it works. Next time I come across a badbot (or Purebot changes it’s name) I’ll just updated this piece of code to ignore their requests.


Search this site


Free apps

  • birthday.sroot.eu – Your birthday or other celebration date based on [years on other planets] / [how many seconds/days] / [how far you’ve travelled around the sun]
  • stampulator.sroot.eu – Calculates the combination and how many 1st, 2nd, large 1st and large 2nd class Royal Mail stamps you need on large envelopes and packets

Recent posts


Archives


Categories