Web Hosting Talk







View Full Version : Cron jobs for UNIX commands


SteadmanTech
12-18-2001, 01:00 PM
Can I use a cron job to perform basic UNIX commands on regular schedules? I am trying to automate some functions on my server and can't quite seem to get it right.

Manually I can Telnet into the server and do the following:
cd /usr/local/www/vhosts/domain.com/htdocs
cp index.html newfile.html

I tried using a cron job to do this by setting up:
0 10 * * * /usr/local/www/vhosts/domain.com/htdocs cp index.html newfile.html

I get email notification (as I do with all cron jobs), but in this case it reports "Permission Denied". Other cron jobs do function as intended.

What am I missing in setting up this one or is it something I can't do? I'm just learning about cron jobs, any assistance is appreciated.

Gary

davidb
12-18-2001, 01:19 PM
Im not too good at this stuff. But, try this:

#minute hour mday month wday who command


0 10 * * * USER cp /usr/local/www/vhosts/domain.com/htdocs/index.html /usr/local/www/vhosts/domain.com/htdocs/newfile.html

jnestor
12-18-2001, 01:26 PM
The command that you're telling cron to run is:
/usr/local/www/vhosts/domain.com/htdocs

That's a directory and not a script or executable and so it can't be run as a command.

Try
cd /usr/local/www/vhosts/domain.com/htdocs ; cp index.html newfile.html

or more simply:
cp /usr/local/www/vhosts/domain.com/htdocs/index.html /usr/local/www/vhosts/domain.com/htdocs/newfile.html

as the command.

SteadmanTech
12-18-2001, 01:33 PM
I tried davidb's suggestion adding the USER into the mix and got a reply email saying, "USER: not found". It referred to my username of course, not "USER".

Now I'll try jnester's suggestion and let you know how that works.

SteadmanTech
12-18-2001, 01:43 PM
jnestor, your suggestion did the trick! I used the "more simply" version of what you suggested.

Thanks you guys!! I knew it shouldn't be all that hard if I could just figure out what the heck I was doing.

Gary