Web Hosting Talk







View Full Version : cron question


MGCJerry
07-12-2002, 12:32 PM
Some of you might know that I'm wanting to learn a *nix environment. (It figures my laptop had to die after installing FreeBSD. The HD started going bad awhile back.) I learn pretty quick by looking at a command and thinking about what it does.

Anyways, I asked my host about a cron job to copy my log file to a different directory. I got a reply with the command listed below (dir names modified). Since I'm on dialup I figured I should zip the log instead.

cp -f /etc/httpd/domlogs/mysitelog.log /home/mysite/public_html

I believe that the command "cp" is copy, the "-f" switch I have no idea what its for (keep owner?), and the rest of the command is pretty obvious (source dir, then destination directory).

Would the following command zip the log and put it in my public_html directory, and leave the original intact if this command was run from a cron?

gzip /etc/httpd/domlogs/mysitelog.log /home/mysite/public_html

thanks in advance :)

SPaReK
07-12-2002, 02:00 PM
The -f paramter tells the cp command to force the copy. That means it will overwrite any files that are there that are of that filename, without asking.

To gzip the file in that directory, you might try:

gzip -cf /etc/httpd/domlogs/mysitelog.log >/home/mysite/public_html/mysitelog.log.gz

Otherwise, you can try two cron jobs:

cp -f /etc/httpd/domlogs/mysitelog.log /home/mysite/public_html
gzip -f /home/mysite/public_html/mysitelog.log

Hope this helps.

MGCJerry
07-12-2002, 05:24 PM
Thanks SPaReK.

I'll use the combined one. I see no need in running 2 crons for something I could do with one. Though I'm wanting to learn *nix the other was helpful too :) Hmm.... the "f" for "force" seems obvious... Duh, me :rolleyes:. Thanks for telling me that :)

Tell me if I'm correct on this assumption about the command above... I'm wanting to make sure I got the right assumptions.

I'm assuming the "-cf" is 2 switches.... the "f" forces the copy and the "c" tells it to copy instead of gzipping the log and moving it.