Help with Cron Jobs


Ok I am new to php SQL, and more advanced forms of web design/coding/programmming or what ever you want to call it. I am currently on Page 17 of a book on php. SO you know my level of experince. Well I thought i would add a small open source game to my website, just to learn and practice php. Well i know basically no! command line stuff. ANd i will be honest, I am super lost, and i have gone to the wiki, and various other sites. I am just lost, if someone has some spare time to help me with baby steps through it that would eb great!..


Sure thing. First of you’ll need to log onto your server via SSH (or telnet). There’s a wiki article on that - but the major points are that you have to edit the user in the panel to allow SSH log in.

Panel > Users > Manage Users > Edit (for the user you want to log in with) and place a tick mark for allowing shell access. click to save the changes. It says it can tak up to two hours, but such changes normally happen in 5 min or less for me.

Next you’ll need a program like putty (for windows). It’s prety easy to set up, connect to with the default settings. Give the user name and pass word and you should be rewared with some ascii text giving the name of your server.

Now you can pick up with the crontab article in the wiki. You’ll be issuing the commands from there in putty. For instance once you log in just type:
crontab -e

to edit your crontab. Let me know if part of that wiki article don’t make sense and I’ll do my best to explain.

–Matttail - personal website


Hey, I’m having a problem actually creating them - when I login to ssh and type crontab -l I just get a permission denied error. Anyone know what to do about that?


crontab -l will list what you have.

You need crontab -e to edit (create) one.



Same problem with trying to create one, list one or anything - permission denied.


Try here: permission denied&Match=And


ok well i go the the text editor and type in

3* * * * /usr/local/bin/php home/user/nameofsite/location of cronfile

I save it in the location

now when i exit out of nano and crontab -l it says there is no crontab exhists for my website…HELP!!!


That tmp file isn’t where crontab belongs. Save the file to myfile.cron (whatever) and then type

crontab myfile.cron

This should import that file into your real crontab file.



when you type crontab -e and save it, it is supposed to save to a temp direcotry. What ever is there by default, is what you should use.
For instance, I just edited one of my crontabs and it saved to this location:
I brought up crontab -e again and this time it saved to

So just take what ever it puts there by default. Just press enter to save the file.

After you press ctrl and o at the same time to save, press enter to accecpt the defulat location/name, then press ctrl and x and the same time to exit, what message do you get back? A success installing new crontab or an error?

I also noticed in your example above you’re missing a space between 3 and the next *. don’t know if that was just a type here, or it’s that way in your cron file.

–Matttail - personal website


It sounds like the main crontab system directory has its permissions set incorrectly. Please file a ticket with tech support and we’ll get it taken care of.


Well now that i do this i atleast get a comment back. Now it says i have a bad minute? IDK what this means I have chaged my minutes various times and i keep geting the same thing


Is your command appearing on two lines? That could be the issue, make sure that your command isn’t wrapping onto an other line. Failing that, copy and paste your crontab here so we can see it.

–Matttail - personal website


How can you avoid this, with the path you need to input? My crontab line is:

11 00 * * * /usr/local/bin/php/home/user/

Which ends up spanning 2 lines. Is there a shorter version of the path to the file?

(Also, is there a way to set it up in the directory above, so that you can’t get to it from a web browser?)


When you edit the crontab and enter a long line, pico (or whatever text editor you’re using) will “helpfully” wrap the command onto the next line. When it does this, simply move your cursor to the start of the second line and press backspace; this should bring your command back onto one line.

Also, that cron command looks wrong to me: at the very least I think you need a space between “bin/php” and “/home”


You can move it if you want as long as no other files need it or they will at least know the full path.

11 00 * * * /usr/local/bin/php /home/user/file.php


Opinions are my own views and not the views of DreamHost. :open_mouth:
Any advice offered by me should be acted upon at your own risk.


It’s quite possible that it needs to stay in that directory, but you could try password protecting that cron directory via Panel’s -> Goodies htaccess feature.



You can also follow These instructions from the wiki. It says to change your default editor, but nano is the default. The big difference is adding the “-w” part. that turns of wrapping. :slight_smile:

–Matttail - personal website