Open Source Web

How to run a script automatically (cron)

2 Comments 17 March 2006

With any business, web-based or brick and mortar, communication with your clients/customers are vital.

For site1 we use our custom-built CRM, for site2 we wrote a script (PHP) to email everyone who has contacted the ******** on site2. Programmers are a lazy bunch, myself and Miguel included, there had to be a way automate this process. We’re going to bundle all this goodness into one Web AddiCT CRM one day soon.
Hello Cronjob

The correct title of this article is crontab. The initial letter is capitalized due to technical restrictions.

The crontab command, found in Unix and Unix-like operating systems, is used to schedule commands to be executed periodically. It reads a series of commands from standard input and collects them into a file also known as a “crontab” which is later read and whose instructions are carried out.

Generally, crontab uses a daemon, crond, which runs constantly in the background and checks once a minute to see if any of the scheduled jobs need to be executed. If so, it executes them. These jobs are generally referred to as cron jobs.

Read more about Crontab

All that is required to run a cron on your website’s server is to telnet or SSH into it. Make sure that your ISP allows you to SSH/telnet. Once that is sorted…

On a Linux machine all this is done from the command line, I would suggest you Putty(Free telnet/SSH client) in from windows.

Type:

crontab -e [select enter on your keyboard --> this will open the editor]
i [select enter on your keyboard]
[Enter the CronJob]
[select esc on your keyboard]
:wq [select enter on your keyboard --> this will save and exit]

I’m not going to go into how-to write a cron, Google for it, or use this Cron Generator to create the Cronjob. Just make sure you chmod 755 the PHP scripts your Cronjob is going to be running.
There we have it, an automated PHP script to stay in contact with the users of site2. You could use it to do almost anything except the dishes ;)

Have you read these yet?

  • I'm sure you have something to say or tweet about this. Why not post a comment below or @rafiq me...

- who has written 1261 posts on Web AddiCT(s);.

Founder of Web AddiCT(s); who tinkers with SEO while dreaming inside a technicolour conversational prism. Follow @rafiq on twitter or join other Web AddiCT(s); on Facebook.

Contact the author

  • http://www.imvusa.co.za Ettienne

    hi i Need to write a ssh script for my email.
    We have a Client in JHB who sent us Mail to account F@imvusa.co.za, then its being forwarded to all 5 other accounts. i on my side need to forward a return email to the F@imvusa.co.za account which need to be forwarded to the 5 other accounts as well as the client. But if any of the 5 other people sents a email to the F@imvusa.co.za account then the client must not recieve it.

  • http://wogan.co.za Wogan May

    I’m no expert, but I’d create a seperate mailing list for that. Internal and external emails really should be kept seperate ;)

    ~ Wogan




Competition SMS Alerts

Mobile Number
+

Change Country

  Unsubscribe
No subscription fees or spam

Get this blog by email: Enter your email address below (You will not be spammed)

© 2011 Web AddiCT(s);. Powered by Wordpress.

Daily Edition by WooThemes modified by FoxinniAfrigator