hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Question about cron jobs
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

Question about cron jobs

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 11-28-2001, 03:34 AM
DeNasio DeNasio is offline
Web Hosting Guru
 
Join Date: Jun 2001
Posts: 275

Question about cron jobs


I'm signing up with Aletia.com to use the cron job feature. But how do cron jobs work? You make a script (like in php) and you tell the system to run this script every day at 12:00am? Is it that simple?

Reply With Quote


Sponsored Links
  #2  
Old 11-28-2001, 03:41 AM
nexcess.net nexcess.net is offline
Junior Guru
 
Join Date: Oct 2001
Location: Ann Arbor, MI U.S.A.
Posts: 217
in a word, yes. you make a script in any number of languages (including php if the php cgi is installed) and schedule it to run at a certain time of day (there are other options as well, but this is one of them).

Chris

__________________
Chris Wells [clwells - at - nexcess.net]
Nexcess - Beyond Hosting
Dearborn, MI DC ● Southfield, MI DC
Wordpress Hosting, Magento Hosting & More!

Reply With Quote
  #3  
Old 11-28-2001, 03:51 AM
smartbackups smartbackups is offline
Web Hosting Guru
 
Join Date: Aug 2001
Location: Dover, DE
Posts: 274
Here is the way to run it, depending on your system log in the do a 'crontab -e' edit it and the save it and it installs automatically.

# minute hour day month day of the week script to execute
# (0-59) (0-23) (1-31) (1-12) (0-6 with 0=Sunday) (executable)
#
0 0 * * * /path/to/your/script

__________________
New Streamlined Sig---
me, myself and I

Reply With Quote
Sponsored Links
  #4  
Old 11-28-2001, 04:14 AM
bobcares bobcares is offline
Root@Bobcares
 
Join Date: Nov 2001
Location: India, US, Germany
Posts: 1,568
To create a cron for a user, log in as the user.

1) su $user
2) crontab -e
3) min hr date mon day /home/$user/$domain-www/path/to/script
where

min - minute (00 - 59)
hr - hour of day (00 - 23)
date - day of month (01 - 31)
mon - month of year (01 - 12)
day - day of week (00 - 06)

4) save changes
5) exit

However where you want a script in php to work you have to put in a little more.
Here's the instructions when php runs only as an apache module

Say you are user star and you want to run a php program(say http://www.star.com/exp.php) from cron and output the results to a file /home/star/phptest2

Telnet into the system as star
create a file (say /home/star/cronjob)
Add the folllowing lines to it



SHELL=/bin/bash

MAILTO=star@starinc.com

0 * * * * /usr/bin/wget -O/home/star/testphp2 http://www.starinc.com/exp.php

The above syntax means that at the start(0) of every hour(*) of every day(*) of every month(*) of every year(*), wget will run the exp.php and output the contents to testphp2. And when this runs, it will send a mail to star@starinc.com
Save the above file
now run crontab /home/star/cronjob
This will automatically add it to cron and execute it at the designated time
If you do not want to output the results anywhere simply omit
-O /home/star/testphp2

To view the contents of cron simply type crontab -l
to remove tasks from cron simply type crontab -r



Say you are user root and you want to run a system critical php program(say http://www.starinc.com/exp.php) every hour from cron and output the results to a file /home/star/phptest2 here's what you do

ssh into the system as root
create a file say( /etc/cron.hourly/phpcron)
Add the folllowing lines to it



#!/bin/sh

/usr/bin/wget -O/home/star/testphp2 http://www.starinc.com/exp.php
save and chmod to 755
Here cron automatically reads /etc/crontab , detects all scripts in /etc/cron.hourly (in our case phpcron) )and executes them
For hourly , daily, weekly and monthly, store your scripts in /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthly respectively


I hope this helps.
Have a great day

Regards
Amar

__________________
A student once asked his teacher, "Master, what is enlightenment?"
The master replied, "When hungry, eat. When tired, sleep. When you need care, come to bobcares...."


Reply With Quote
  #5  
Old 11-29-2001, 10:56 AM
MikeMike MikeMike is offline
Junior Guru Wannabe
 
Join Date: Jun 2001
Posts: 66
how do you start a cron job every 10 minutes?

Regards
Michael

Reply With Quote
  #6  
Old 11-29-2001, 11:04 AM
bteeter bteeter is offline
Web Hosting Master
 
Join Date: Jan 2001
Location: Kihei, HI
Posts: 576
Quote:
Originally posted by MikeMike
how do you start a cron job every 10 minutes?

Regards
Michael
You can specify multiple minutes, hours, days, etc in cron jobs using the comma. For example:

0,10,20,30,40,50 * * * * /path/to/10minscript

Will run the script /path/to/10minscript every 10 minutes. So long as you don't put a space between the minute values you are OK.

Take care,

Brian

__________________
:: 1StopWebHosting.com :: - Professional Web Hosting Services
::
:: Featuring the CPanel Control Panel running on CENTOS Linux servers
:: We offer Shared Web Hosting, Business Hosting, Java / J2EE Servers and Dedicated Server solutions.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Jelastic Launches Version 1.9.1 of Java and PHP Hosting Platform Web Hosting News 2013-05-21 09:39:09
Web Hosting Sales and Promos Roundup – June 22, 2012 Web Hosting News 2012-06-22 16:36:15
Web Host XIOLINK Completes Expansion at St. Louis Data Center Web Hosting News 2012-01-18 16:01:09
1.3 Million User IDs and Passwords Stolen in Washington Post Jobs Site Hack Web Hosting News 2011-07-07 14:41:28
iCloud Rumored to Mean Discontinuation of Apple's iWeb, MobileMe Hosting Web Hosting News 2011-06-13 20:27:40


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?