Cron


#1

Sorry, but I dont get it. I need to schedule a “cron” job. I have shell access, and I know what I have to do when I get there, but how do I get there.

Thanks


#2

The wiki is your friend:
http://wiki.dreamhost.com/index.php/Crontab
Be sure to follow some of the links for PuTTY, SSH, and the bottom section about Editing your Crontab file.

-Scott


#3

Scott–
I appreciate the reply, but I’ve been reading that page the better part of the afternoon. I’m a windows guy and new to Unix/Linux. Just need a cron job-- SSH is necasarry? dont understand why it would need to be secure, but… Do I need a client on my Windows box for SSH? Can’t I just edit a file through FTP?
Sorry about the newbie questions, but something isnt sinking in

Thanks.


#4

You can’t edit the file through FTP because the file isn’t saved in your home directory. You have to log into the shell. However, you can get started with FTP:

  1. Create a single line file called cron.txt that contains:
    30 * * * * /full/path/and/command
    This will run the command at half past every hour. Your software may tell you when the command needs to run.

  2. FTP the file into your home directory.

  3. Log into your shell account using PuTTY to get to the command line.

  4. Type the following command to enter your file into the cron system:
    crontab cron.txt

  5. To verify that it’s in, type:
    crontab -l
    (that’s the letter “ell”) This should echo back what was in your cron.txt file.

-Scott


#5

Scott–
All set. Thanks for taking the time.

Adman


#6

Cool, I’m glad it worked out for you.

-Scott


#7

I’m receiving an error while trying to install a couple of cron jobs. Message is “bad day of the week, error cannot install”

Cron.txt contents;

15 **** curl -s-o/dev/null http://mysite.com/cgi-bin/moxiebin/bm-maint.cgi
60 **** curl -s -o /dev/null http://mysite.com/adserver/maintenance/maintenance.php

Thanks


#8

[quote]15 **** curl -s-o/dev/null http://mysite.com/cgi-bin/moxiebin/bm-maint.cgi
60 **** curl -s -o /dev/null http://mysite.com/adserver/maintenance/maintenance.php[/quote]
I believe you need to add spaces between the ‘*’ characters. Also, I think you need to specify the full path to your command.

something like…

[color=#0000CC]15 * * * * /usr/bin/curl -s -o /dev/null http://mysite.com/cgi-bin/moxiebin/bm-maint.cgi
60 * * * * /usr/bin/curl -s -o /dev/null http://mysite.com/adserver/maintenance/maintenance.php[/color]

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#9

Thank you Mark–
Now I’m receiving a different error" bad minute errors in crontab file, can’t install.

Thanks again.


#10

Mark–
I got it-- "*/15…

Thanks


#11

I’m sorry, I should have picked this up before. The valid range for the minute field is 0-59, so your 60 is out of range.

Try…

[color=#0000CC]15 * * * * /usr/bin/curl -s -o /dev/null http://mysite.com/cgi-bin/moxiebin/bm-maint.cgi
0 * * * * /usr/bin/curl -s -o /dev/null http://mysite.com/adserver/maintenance/maintenance.php[/color]

Edit: The first cron entry will execute at 15 minutes past the hour and the second one will execute on the hour.

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)