Language English English Español Español Deutsch Deutsch Português Português
🇬🇧 English 🇪🇸 Español 🇩🇪 Deutsch 🇧🇷 Português
Language:EnglishEnglishEspañolEspañolDeutschDeutschPortuguêsPortuguês

Running a PHP script with a Cron job in 1and1

Following on from running my first cron job with 1and1 hosting what I really wanted to do was to be able to run a php script, perl script or some other form of script on a timed basis. This article is a description of setting up a cron job on 1and1 hosting to run a simple “hello world” style example.

First I set up my helloworld.php script, this was a simple script to create a file called helloworld.txt and write the words “hello world” to that file and save it.

I tested this file by running it on my server and it worked fine. The next thing I had to do was log on to my 1and1 server using SSH, the program I use for this is PuTTY which I have been using since university and works well. The next two steps you have to go through are: 1. to find the location of your current directory: enter “pwd” to find this. 2. to find the location of php on your machine.

Now I had to create my crontab file. So I entered the command “crontab -e” (which means edit crontab) and came to the VI editor. Using this command I found that on 1and1 hosting my helloworld.txt file was updated between 14 and 18minutes past every hour.

I know this description would have helped me had it been available when I was looking for information on running a php file through a cron job on 1and1. I hope it helps you.

Get my marketing cheat sheets at Click Here

Comments

Leave a Reply

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