|
Answer
by: George Kaloyanov, Aplus.Net Knowledge Base Support
Cron
Jobs are supported with Aplus.Net’s Unix-based shared hosting
plans. Cron Job is used on a Unix operating system to schedule commands
to be executed periodically. You will need to activate your SSH access
to the server in order to set your own cron jobs. You have to update
the contents of your Cron Table text file in order to add your new cron
job to it. You can do that by executing the following command:
‘crontab –e’. This will open the crontab
file for editing. Note:
If this is your first cron job, the ‘crontab
–e’ command will also create the initial crontab
text file. Each
Cron Job has 6 components:
- Minutes:
From 00 to 59 -> the exact minute the cron job executes
- Hour:
From 00 to 23 -> hour of the day the cron job executes (0 =
midnight)
- Day:
From 00 to 31 -> day of the month the cron job executes
- Month:
From 01 to 12 -> month of the year the cron job executes
- Weekday:
From 00 to 06 -> day of the week the cron executes (Sunday = 0,
Monday = 1, and
so on)
- Command
-> the exact command that has to be executed.
CRON
JOB EXAMPLES: In
the following examples we will use a PHP script file (cron.php) which
you want to run periodically. However, you can set up cron jobs for any
supported languages such as Perl or Python. Since PHP is located at
/usr/local/bin/php and the full path to your PHP script file is
/home/partition/yourFTPusername/html/cron.php, here is what you need to
have in your crontab text file: - 25
22 * * * /usr/local/bin/php
/home/partition/yourFTPusername/html/cron.php – the script
will be executed at 22:25 each day.
- 00
22 * * 01 /usr/local/bin/php
/home/partition/yourFTPusername/html/cron.php – the script
will be executed at 22:00 on every Monday.
- * 3,4
* * * /usr/local/bin/php /home/partition/yourFTPusername/html/cron.php
– the script will be executed at 3AM and 4AM each day.
Note:
How
could I find the full path to my web hosting directory?
CRON
JOBS RESTRICTIONS:
- Your
cron job should not run more than once every hour.
- The
process should not open ports on the shared hosting server.
- The
process should not use more than 50% of the shared hosting server
resources (CPU, Memory).
- The
process should not run for more than several minutes.
Important:
If your cron job does not meet any of the requirements above, your
shared hosting account might be suspended by Aplus.Net’s
administrators. Related
links: |