Crontab


#1

is there a way to set that in cpanel?
or i have to ssh?


#2

By CPanel I guess you mean DreamHost’s Control Panel (they are not using CPanel, but their own custom built control panel)?

Anyway, you have to set your cronjobs via ssh at DreamHost.


[color=#000000]DreamHost Promo Code[/color]: [color=#CC0000]Save $50[/color] with the promo code DREAMTEAM


#3

This Wiki Article should be of some help. I just revised it a little so things are hopefuly a little clearer.

-Matttail


#4

The Wiki article is great, but I’m not totally clear on where my crontab file needs to be saved in order to ensure that it actually gets executed. I have to assume that my default folder under /tmp is incorrect.


#5

The ‘crontab’ command command listed in the Wiki will save the cron file in its proper location. There’s no need to tell it where.

-Scott


#6

When I saved mine, it defaulted to /tmp/crontab.NIK3Db/crontab, and the tasks I defined did not appear to run. Does this indicate a syntax problem in my cron file itself, or this is not a good location?


#7

I think that’s a temp file the editor uses, but the real file does get saved.
Do a ‘crontab -l’ to see what’s in your crontab file.

If crontab -l does show that you have commands in there and are still having problems, post the text of the file here so we can look for errors.

-Scott


#8

Do managed web hosting (shared) users get access to setting up cron jobs? I need to set one up to run a blog aggregator script every hour (no, it’s not shady. It’s me and two friends trying to get entries from each of our blogs on the front page of a single blog, while maintaining our independence).


#9

Yes!
http://www.dreamhost.com/shared/comparison.html


[color=#000000]DreamHost Promo Code[/color]: [color=#CC0000]Save $50[/color] with the promo code DREAMTEAM


#10

Here is what I have currently. These commands do work when I run them manually over SSH (removing the portion before perl first).

[i]0 3 * * * perl /home/EXAMPLEUSER/awstats/tools/awstats_buildstaticpages.pl -config=EXAMPLESITE1.COM -update -awstatsprog=/home/EXAMPLEUSER/awstats/awstats.pl -dir=/home/EXAMPLEUSER/EXAMPLESITE1.COM/awstats/

15 3 * * * perl /home/EXAMPLEUSER/awstats/tools/awstats_buildstaticpages.pl -config=EXAMPLESITE2.COM -update -awstatsprog=/home/EXAMPLEUSER/awstats/awstats.pl -dir=/home/EXAMPLEUSER/EXAMPLESITE2.COM/awstats/

30 3 * * * perl /home/EXAMPLEUSER/awstats/tools/awstats_buildstaticpages.pl -config=EXAMPLESITE3.COM -update -awstatsprog=/home/EXAMPLEUSER/awstats/awstats.pl -dir=/home/EXAMPLEUSER/EXAMPLESITE3.COM/awstats/[/i]


#11

Use a full path for perl: /usr/bin/perl

-Scott


#12

Literally, like this? No worky. (Please forgive my infantile Linux/Unix knowlege).

[i]0 * * * * /usr/bin/perl /home/EXAMPLEUSER/awstats/tools/awstats_buildstaticpages.pl -config=EXAMPLESITE1.COM -update -awstatsprog=/home/EXAMPLEUSER/awstats/awstats.pl -dir=/home/EXAMPLEUSER/EXAMPLESITE1.COM/awstats/

15 * * * * /usr/bin/perl /home/EXAMPLEUSER/awstats/tools/awstats_buildstaticpages.pl -config=EXAMPLESITE2.COM -update -awstatsprog=/home/EXAMPLEUSER/awstats/awstats.pl -dir=/home/EXAMPLEUSER/EXAMPLESITE2.COM/awstats/

30 * * * * /usr/bin/perl /home/EXAMPLEUSER/awstats/tools/awstats_buildstaticpages.pl -config=EXAMPLESITE3.COM -update -awstatsprog=/home/EXAMPLEUSER/awstats/awstats.pl -dir=/home/EXAMPLEUSER/EXAMPLESITE3.COM/awstats/[/i]


#13

After you save and exit from editing your cron file, what message do you get? A success message, or something about the time being wrong?

-Matttail


#14

If you cut and paste the commands with the full path, does it work?

Did you type in ‘crontab -l’ to see if you actually have a crontab file?

-Scott


#15

After editing I get prompted to save, choose yes, get prompted for filename to write (/tmp/crontab.ld88he/crontab) and it saves w/o a problem (‘installing new crontab’).

If I copy and paste the commands it executes fine (the real commands contain real paths/users).

If I type in ‘crontab -l’ it does display the same commands as what I see in the editor (‘crontab -e’).


#16

I believe that there’s an error with your user’s setup. It seems everthing is in working order.

However, you should do a few final steps before contacting support. First off put this at the top of your cron file
MAILTO:"you@domain.com"

This will send any error messages you might be getting to your E-mail address. Also, make sure there is at least one blank line at the bottom of your cron file. With these things in place, and if you’re sure it’s not running - then contact support.

On a side note, there’s a easier way to get your commands to run every 15 min besides putting in a new entry. for instance:
*/15 * * * * /usr/bin/perl …

Will run your command every 15 min. You can also list min if you’d prefer:
2,8,29,45,51 * * * *

Same goes for all the other fields, if you want specific days or whatever.

-Matttail


#17

I don’t use a MAILTO just because I don’t want to hear back from cronjobs.

Does the blank line at the end screw up the whole crontab, or just the last entry?

The crontab this person is setting up is to run awstats on three different domains, hence the three entries.

-Scott


#18

That’s fine once you have them working - but expecially in a situation like this you’d want to know what kind of an error message you’re getting.

You should have a blank line at the end, as I’ve heard from others on this forum it seems it’s necessary.

Didn’t catch the different domains.

-Matttail


#19

Thank you for the suggestions. You’ve all been extremely helpful.

When I attempt to add the MAILTO to the start of the file (exactly as you showed, with my own yahoo.com address) I get an error upon saving:

“crontab: installing new crontab
”/tmp/crontab.KnLRmM/crontab":0: bad minute
errors in crontab file, can’t install.
Do you want to retry the same edit?"


#20

sorry, that should be
MAILTO="you@domain.com"

Also, I’m not sure, but it may have to be an E-mail address hosted by dreamhost.

-Matttail