Bob's Good Stuff Lists

Powered by Gossamer Threads

How to Automate
Links Rebuilds and Link Verification
Using Crontab

Copyright © 2000 Connors
All Rights Reserved

*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*

These instructions may be used for personal use only. All other rights to the instructions are reserved, under copyright, by the author. Redistribution or republication of these instructions, without permission, is prohibited.

Purpose:

Many people who are using the Gossamer Threads, Inc's Links scripts want a way to automate the rebuilding of the pages instead of having to do it manually from the admin screen or from a shell account login. These instructions will allow you to do that provided your web host allows you to set up cron events using crontab and you have access to your site via a shell (telnet) account to make the appropriate crontab entry. These instructions assume you are using a Linux system.

These instructions can also be used to automate the execution of nph-verify.cgi with the appropriate modifications. Just change references to nph-build.cgi to nph-verify.cgi, rename the log files accordingly, and rename build_links.sh to verify_links.sh, being sure to change the content of that file to point to the correct script and log file. You should not run the rebuild and link verification at the same time; besure to allow plenty of time between each event so that only one event has access to the Links database at any time.

Instructions:

  1. Login to your shell account and go to your Links admin directory.

  2. If it does not already exist, create a directory called logs by issuing the command:
    mkdir logs
  3. Set the permissions on this directory to full access/read/write:
    chmod 777 logs
  4. Create a file called build_links.sh containing something like this:

    # Remove backup and new files before rebuild
    touch /path/to/cgi/links/admin/backup/junk
    touch /path/to/web/links/New/junk
    rm /path/to/cgi/links/admin/backup/*
    rm /path/to/web/links/New/*
    
    # Rebuild Links pages and log actions
    /path/to/cgi/links/admin/nph-build.cgi > /path/to/web/links/admin/logs/build_links.log
    The first 5 lines are optional and are used to 1) ensure something is in the two directories before 2) removing all files in the two directories. If you do not want to remove your backup files or the files in your New directory, you can either omit those lines or add lines to copy the contents of those directories elsewhere. Also, those 5 lines should not be included if you are using these instructions to create an automatic link verification event.

    The last line will rebuild the pages and write output to the log file in case you need to look at what was done. It will always overwrite the current log file, so you don't have to worry about the log becoming too big.

    The /path/to/cgi/links/admin/backup is where your Links backup files are located in your cgi directory. The /path/to/web/links is where your Links pages are built. Be sure to change both paths to match your Links setup.

  5. Upload the build_links.sh file to your root directory (not your root web directory, but the directory you are in when you first telnet to your system). Be sure you upload the file in ASCII mode.

  6. Make the build_links.sh file executable:
    chmod 744 build_links.sh

  7. Create another file, mycron.txt, and upload it (in ASCII mode) to your root directory. You should not need to change its permissions. The file should contain something like this:
    # (Re)Build the Links HTML Files each day at 1:00 a.m.
    0 1 * * * /path/to/build_links.sh
    This is the cron event that will be loaded into the cron table. Here is how the event breaks down:
    0 1 * * * /path/to/build_links.sh
    - - - - - -------------------------------
    | | | | |          |_____ command to execute
    | | | | |________________ day of week
    | | | |__________________ month of year
    | | |____________________ day of month
    | |______________________ hour of day
    |________________________ minute of hour
    The asterisks (*) indicate null (no setting). The event will run at 1:00 a.m. each day. If your server is in a different time zone than you are, be sure to take into account the time difference before thinking it has not run. For example, if you are in the Eastern USA Time Zone but your server is in the Pacific USA Time Zone, the event will actually run at 4:00 a.m., your local time.

    You can also setup the event to run every so many hours on a daily basis. For example, let's assume you want to run the event every six hours, starting at 1:00 a.m. To do this, change the event to:

    # (Re)Build the Links HTML Files Every 6 Hours at 1/7 a.m. and p.m.
    0 1,7,13,19 * * * /path/to/build_links.sh
    All we did here was add comma seperated times (01:00, 07:00, 13:00, and 19:00) under the hour of the day column.

  8. Once that file is uploaded in your root directory, issue the command:
    crontab mycron.txt
    If all goes well, that will load the event into your cron table. You can ensure it is there by issuing the command:
    crontab -l
    If the event loaded correctly, it will list. If it does not list, then you will need to contact your system admin for instructions on how to load a cron event on your system.

    If it loaded, you are all set to go. It should run at the scheduled time(s).

*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*:=+=:*

This Site Hosted By
Orphanage Services
Powered By Apache