Help with Cron Jobs


#1

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!..


#2

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 yourdomain.com 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
art.googlies.net - personal website


#3

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?


#4

crontab -l will list what you have.

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

-Scott


#5

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


#6

Try here:

http://discussion.dreamhost.com/showthreaded.pl?Cat=&Board=forum_programming&Number=45288&Search=true&Forum=All_Forums&Words=cron permission denied&Match=And


#7

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
/tmp/crontab.70nxDv/assxcron

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


#8

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.

-Scott


#9

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:
/tmp/crontab.coBxlW/crontab
I brought up crontab -e again and this time it saved to
/tmp/crontab.Mxs8LS/crontab

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
art.googlies.net - personal website


#10

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.


#11

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


#12

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
art.googlies.net - personal website


#13

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

11 00 * * * /usr/local/bin/php/home/user/www.finalfurlong.org/cron/file.php

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 www.finalfurlong.org, so that you can’t get to it from a web browser?)


#14

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”


#15

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


Norm

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.


#16

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.

-Scott


#17

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
art.googlies.net - personal website