Cron is intended for experienced webmasters who are familiar with the Unix environment. If you have not used cron before, it is highly recommended that you contact a professional to assist you in setting it up. The tech support we provide for cron is limited, so it is very important that you have an experienced person working on it.
Before you begin working with cron, it is imparitive that you have at least a basic understanding of several concepts, and have the proper access to your server. Without knowing these things, you will have an extremely difficult time getting the cron scripts to work properly.
Your server must allow the following:
- Telnet or SSH access
- crontab access
- Ability to setup multiple cron jobs
- You will need wget installed on your server
If you are not sure that your hosting company allows the above access on their servers, contact them before you begin. You will not want to spend the time getting everything configured, if you do not have the proper priveleges to run the cron jobs on your server.
You must understand each of the following:
- Unix commands (cd, chmod, etc)
- Uploading files in ASCII mode
- Full Unix directory paths
- Using telnet or SSH to access your server
If there is anything you do not understand in the list above, you will need to educate yourself on that item(s) before you proceed. Our tech support staff will assist you if you run into problems, however we simply do not have the resources to educate people about the items above. There are many tutorials available on the WWW covering most of the items above. Take the time to learn about them if you don't already understand them.
Cron jobs are a way of automating tasks that you want done every week/month/day and at a certain time. To accomplish this, you will make crontab entries on your server which will tell it when it needs to run the command you want.
An entry consists of two parts - a time to run, and a command to run.
The time to run (the first part of the entry) is broken up into 5 fields:
1. minute of the hour
2. hour of the day (on the 24 hour clock)
3. day of the month
4. month of the year (1 = January, 2 = February, etc.)
5. day of the week (0 = Sunday, 1 = Monday, 2 = Tuesday, ..., 6 = Saturday)
A * in one of these fields indicates that the job should be executed at any or every one of these, so for instance a * in the month of the year field means that this task should be carried out every month at the time specified in the other fields. A * in the day of the week field, when there is something in the day of the month field, does not mean that this task should be carried out every day, but rather that it should be carried out on the appointed day of the month regardless of what weekday it is. Only *s in the day of the week field, and the day of the month field, and the month of the year field would indicate a daily task.
In the examples, [command] represents the full path and filename of the file you want to execute.
The job with this time to run would run every Sunday at 12:20 am.
20 0 * * 0 [command]
This job would run at midnight on any Friday the 13th.
0 0 13 * 5 [command]
You don't have to put just one time in a field. This job, for instance, would run every day at 12:30am, 2:30am, 4:30am, 6:30am, 6:30pm, 8:30pm, and 10:30pm:
30 0,2,4,6,18,20,22 * * * [command]
This one would run every Tuesday and Friday at 5:30 am:
30 5 * * 2,5 [command]
To get started you will need to locate the wget program on your server. This is a program that is commonly available on Linux and Unix servers, but not always. If you do not know where it can be found, contact your server administrator to get that information. You will need the full path to the program (ie /usr/bin/wget). If you don't have wget on your server, ask your server administrator if they will install it.
The next thing to do is edit the cron.php file in a text editor. You should change the $WORD value to a secret word that you will use to identify yourself as a valid user of the script. If you leave it as the default, people will be able to rerank and reset your list through a browser if they know the default value. You can change this to any string you want that contains English letters or numbers. Once you have changed the word, save cron.php and upload it to your server to the same directory where arphp.php is located.
Now you can open the supplied cronfile in a text editor. In this file you will need to replace http://www.yoursite.com/toplist/cron.php with the full URL to cron.php on your server. You will also need to locate the text 'yourword' and replace it with the secret word you entered in cron.php. Example:
Locate --header="M: rr-yourword" and replace yourword with your secret word. If you selected at54S8 as your secret word, this would become --header="M: rr-at54S8"
You will need to do this for both of the lines containing cron commands. At this point you should also make the necessary changes to the time settings so the updates occur when you want them. The final thing to do is replace all occurances of /path/to/wget with the full path to the wget program on your server. Once you have made all the changes, save the file and upload it to your server in ASCII mode to the same directory as cron.php. If you have other cron jobs running on your server, be sure to include them in the cronfile you upload.
You now need to login to your server through telnet or SSH. Once you have a command prompt, change into the directory where you uploaded cron.php and the cronfile. Issue the following command to enter your cron jobs in the system:
crontab cronfileThis will enter all of the commands in cronfile, and the server will begin executing them at the selected times. To double check your crontab entries, you can issue the following command:
crontab -lOnce you have checked that the crontab entries are setup, change the permissions on the cronfile to 600 or remove it from your server. You do not want people viewing this file because it contains your secret word.
Once you have everything above completed, you will probably want to test out your setup. This is done through your telnet or SSH connection. All you need to do is take all of the text following the last time entry and run it from the command line. For the example cronfile provided with the software, this command would be:
/path/to/wget -O /dev/null -q --header="M: rr-yourword" http://www.yoursite.com/toplist/cron.php
Copy and paste the command you have in your cronfile to your command prompt, and hit enter. You should be returned to the command prompt within a few seconds, and there should be no output. If you get any error messages you will need to check over your setup again. If you get no error messages you can login to the administrative interface and look at the last rerank time. It should have occurred a few seconds ago, and cron.php should appear in the parenthesis.