Cron


#1

Hello, im loging in via Telnet and I get the following prompt:
“cortes:~/”

How do I change that to an directory named “email”? Does anyone know the path to that, email is a folder in my account. I know nothing about cron, and am just learning for now. Thanks!


#2

Well…

First lets start with some basics; Telnet or ssh is “A packet-based binary protocol that provides encrypted connections to remote hosts or servers” What this means basically is that it’s a way of connecting to your server. Kinda like remote desktop connection with Windows XP it’s a way for you to get access to the system with out physically sitting down infront of it.

Next CRON, Cron jobs, or Crontab: The crontab command, found in Unix and Unix-like operating systems, is used to schedule commands to be executed periodically. It reads a series of commands from standard input and collects them into a file known also known as a “crontab” which is later read and whose instructions are carried out. I think this one is a little simpler in concept. You can set up the server computer to automagically carry out a set of commands to accomplish any number of thigns at a given time or on a regular basis with out human intervention.

You can use Windows Telnet or a program called putty for ssh access. You will need to specify (for windows telnet) that you are using a tcp/ip or internet connection. Then give it the address. You should have gotten the information with your welcome E-mail - but for you it should be cortes.dreamhost.com (as that is the name of your machine as you posted). then you’ll get a login prompt. You have to log in with a user that has been granted shell access, not just FTP access. Once you have secussfully typed in your user name and password you’ll be presented with a welcome message and the prompt.

Now you can type in commands and will get responses back in text format. This Kbase article outlines some basic commands you can give and what they do. So when you get:
"[joe] $" you can type in “ls” to get a listing of all the files and directories in the current folder. you use “cd” to change directories.

Now, if you want to set up a Cron Job this is entirley an other issue. This article will show you how to set up cron. The only difficult part about setting up a cron job is makign sure you set it up to issue the commands that you want. You can use the cron file to carry out the entir command, or if your desiers are more complicated you might want to set up a foo.sh file for cron to execute.

As you get more familiar with how this all works, post back wtih specific questions that you run into, like “how to I accomplish this?” and the like.

Good luck!

-Matttail


#3

Hi –
People could tell you how to see into your email folder over Telnet… but this probably isn’t something you want to do. That’s not how to check your email. For most of what you might want to do (including configuring your website and email) you can find information at http://panel.dreamhost.com.

Sometimes you may need to Telnet into your server, but if you don’t have any experience with a UNIX or Linux command-line this can be dangerous – for example, if you type the wrong command you could delete all of your email, or your entire website, etc… There is no “undo” command.

If there is something you really need to do over Telnet, you can ask here for detailed instructions – then you’ll need to copy them exactly. Every space, every capital or lower-case letter, every dash, every symbol must be exactly correct or you’ll get an error (or worse, the command will complete but it won’t do what you wanted!).

I don’t want to exaggerate – command-line interfaces aren’t some kind of black magic! – but they are not nearly as friendly as what most people are used to.


#4

Alright, I got the file finished, however when I try to install it I get the following error: “cron.tab”:0: bad minute

1 * * * * usr/local/bin/php -q /home/cozyskin/cozyskin.com/email/users/send_emails.php

30 * * * * usr/local/bin/php -q /home/cozyskin/cozyskin.com/email/users/send_autos.php

What am I doing wrong?


#5

Can’t see a thing wrong with the two lines you posted, but that doesn’t account for what might be extraneous (or missing) non-printing characters.
How did you create the file?
And what was the syntax of the “crontab” command you issued to get that error? (I can’t even reproduce the error message you got.)


#6

I made the file in notepad and saved it as cron.tab, as unicode. I then telnet into my server and type “crontab cron.tab” and it gives me that error. =/


#7

That’d probably be the cause of the “extraneous/missing character” problem I mentioned previously.
Don’t bother with the unicode nonsense - just save the file as a flat ASCII text file, preferably with a “.txt” extension, (which most FTP clients will recognize as requiring an ASCII mode transfer). Call it “crontab.txt” or “jobs.txt” or somesuch, then just FTP the file normally. If possible, verify that your FTP client is indeed aware that a “.txt” extenstion must transfer in ASCII (not Binary) mode.

Then just issue your crontab command again with the appropriate filename.

ps. since you’ve obviously got at least a mild grip on unix shell commands, you should probably familiarize yourself with an editor. Despite what the DHKB says, “vi” works perfectly well for editing a crontab input file, but if you’re a unix “rookie” you may want to use “nano” or “joe” instead.

ps. Just my humble (and uninformed) opinion, mind ya, but from the looks of things it seems as though you may be running a script that sends batch email every single minute of the day. This may not be such a very good idea at all, but since I have no real idea of what you’re really up to, I can but issue a mere caveat.


#8

Okay, i tried that and now it gives me the error “cron.txt”:1:bad minute

Maybe I wasn’t meant to get this script working? lol


#9

Wow, so cron is involved. That first post was so confusing. Anyway…

Nah – that’s only if it has * for the minute param. Cron doesn’t have an option for “run command every x minutes”; it’s a pattern-matching thing. The minutes field as written will only match once an hour at x:01. If you want every 5 minutes, for instance, you have to write something like:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * commandI’ll concur with netdcon about the fix, though… make sure you upload the file as text. Or paste it into an editor on the server itself. I’m a vi guy, so that would go like this (don’t type the spaces between commands, or the brackets around key names):

vi new_crontab.txt i [paste] [Esc] :wq crontab new_crontab.txt Also if you just type crontab -e that’ll take you directly into editing your crontab (so when you save it will be installed automatically) – I’m not sure which editor by default (I think I remember setting my default editor to vi…).

When you do get it installed, you may start getting errors out of cron (these will be emailed to you automatically) – for one, cron executes commands starting in your home directory, so unless you put a slash in front of that php path it will try to execute /home/cozyskin/usr/local/bin/php (which is probably not what you want, unless you compiled your own php to that location!).

You can check that the path to send_emails.php is correct by trying to change into that directory, and if that works, listing the files:

cd /home/cozyskin/cozyskin.com/email/users/ ls -l


#10

Thanks for posting those suggestions–I’ve been using pico because vi quite frankly scares the crap out of me (it didn’t help that a couple of times I typoed it as “ci” which turned out to be a command and did something strange to the file I was trying to open), but after doing a search on the editors you mentioned, it’s looking like joe might be able to do more/be easier to work with than pico.


#11

[i]If you want every 5 minutes, for instance, you have to write something like:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * command [/i]

Or, simply,

*/5 * * * * command

If you want useful replies, ask smart questions.


#12

Okay, I’m just confused - I tried my own instructions and I still can’t reproduce this error.

I’m going to recommend that you get into the shell and use “nano” to edit that crontab file (whatever the name of it may be). Caveats:

  • make sure to leave a blank line at the bottom of the file.
  • you may wanna make a couple of practice runs first.
    …but really, what you’ve already done should have worked. I also agree that what jtheory writes above should also work, so if that seems easier to ya, by all means give it a shot. But in the long run, learning to cope with one of the unix-based editors offered on shell will probably serve you best in this and other future endeavors.

ObHomer: D’OH! :blush:
I brain-farted that one pretty good; so much for 20+ years of systems admin experience.


#13

I am seeing the same problem in my account. I was getting duplicated CRON calls so I blew away all my jobs and now when ever I enter a new job time I get the same error. I am using the same syntax that worked a few weeks ago and I am using Nano so this in theroy should work.

I have tried adding a space before the min, a line before and after the job line, etc. Nothing seems to work and I keep getting the bad min. error. Any ideas?

— update —

I found the answer thanks to a thread in programming. The issue was the fact that Nano is wrapping my line of text and blowing up crontab. I just wrote out a TXT, FTP’d it up and then set it via this:

crontab my_file.txt

thanks all!


#14

you could also use “nano -w” to force it to not wrap long lines.

-Matttail