How to run a script automatically (cron)

Your are the first person in your social graph to know! Share it with your wwworld now 🗺️

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.


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 😉

Your are the first person in your social graph to know! Share it with your wwworld now 🗺️

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.