Crontab help!

Crontab help!

Posted by: saygoodbye
Posted on: 2006-02-25 20:04:00

I really don't understand how this works...

I have a file named "crontab" under my /home/user/ect directory, correct?

Ok then I built the inside:
* * * * * cp -u /home/user/domain/cgi-bin/ /home/user/domain/stats/

But why doesn't that work? Shouldn't it copy the content of stats into the cgi-bin? (Though this is just for testing, I would like to be able to move the content of stats for my massive stats program im working on...)


Re: Crontab help!

Posted by: matttail
Posted on: 2006-02-25 20:28:00

well, first off check out this Wiki Article. That will help some I suspect.

Your first problem is that just putting a file called cron in your home direcotry won't do anything. You'll need to type "crontab -e" to edit your crontab, or you could use "crontab filename" -replacing filename with an actual text file, to import that file as your crontab (and overwrite anything already there). If you're editing the crontab then once you're done you're press ctrl-o to save the file and ctrl-x to exit. After either command is carried out you will (hopefully) get a success message about the new crontab being installed, or an error message.

Next, I don't think that you really want your script to run that often... I'm not actually sure how often it will run they way you have have it set up, but it's a lot. I tested to see if that was even a valid setting, and it was accecpted, but... Read the wiki article to understand how specifying the time works, and decided how often you really want it to run.



-Matttail

Re: Crontab help!

Posted by: saygoodbye
Posted on: 2006-02-25 20:33:00

Of course its not going to run every second... most likely that would kill the server load or something... but what do I use to enter these commands in I use winFTP (windows defualt ftp client), should I be using telnet?


Re: Crontab help!

Posted by: matttail
Posted on: 2006-02-25 20:42:00

ya, sorry you -you need to enter thoes from the command line on your server. SSH is the best way to do that (a secure version of telnet) pick up a program called putty.

Also, for ssh access, your user must allow that through the panel > Users > Manage Users > Edit > Tick mark for ssh access.

I think that using five * sets it to run once every minute. It's not really a standard way of doing things, and I doubt that you need the file copied out that often anyways.



-Matttail

Re: Crontab help!

Posted by: saygoodbye
Posted on: 2006-02-25 21:05:00

Ok got Putty, my question now is how do I enter a cronjob? Im lost mostly because of the DH tutorial!


Re: Crontab help!

Posted by: matttail
Posted on: 2006-02-25 21:10:00

type:
crontab -e

That will bring up the efault text editor (nano) and then you can paste in your crontab line.
Once you've got it right, press ctrl and o at the same time, then ctrl and x. You will hopefully get a message like "successfully installed new crontab".



-Matttail

Re: Crontab help!

Posted by: saygoodbye
Posted on: 2006-02-25 21:16:00

ok I think I have it! I have it running off a file, now if I update this file will the cronjob go witht he update or is it cached?


Re: Crontab help!

Posted by: matttail
Posted on: 2006-02-25 21:18:00

it will go with the update. (not cached)



-Matttail

Re: Crontab help!

Posted by: saygoodbye
Posted on: 2006-02-25 21:27:00

Alright then it still is not working...

1 * * * * cp -R /home/user/domain/statistics /home/user/logs/domain/http.1733358/html

Is my new command... any debugger?


Re: Crontab help!

Posted by: matttail
Posted on: 2006-02-25 23:27:00

well, to be sure I'd need to know what the error you're getting is...

But I'm thinking you're got the directories backwards. You command should reflect this:
cp -r /path/to/origional/file /path/to/new

Also, I assume you've just edited your command to protect privacy... but you are using the proper user name and domain folder, right? It may help to check your command by running it from the command line to see if it works, or what error you get. (just ditch the cron-timing part)



-Matttail

Re: Crontab help!

Posted by: saygoodbye
Posted on: 2006-02-26 13:44:00

I don't need the cron timing part?

And yes im just trying to protect my privacy, so that should all be fine, my real problem now with the message is that my folders don't have the right permissions, so I tried to change them via ftp, but it keeps failing to change the permissions....


Re: Crontab help!

Posted by: ardco
Posted on: 2006-02-26 15:15:00

> cp -R /home/user/domain/statistics /home/user/logs/domain/http.1733358/html

cp command syntax is: copy from to

so, you're trying to copy from your directory to the logs directory, which is owned by root, and you do not have permissions to do that.

You need to reverse the order:

cp -R /home/user/logs/domain/http.1733358/html /home/user/domain/statistics

Good luck,

BobS

Tags: cgi bincrontabstats programpromo codehelp