Web Hosting Talk







View Full Version : Setting a cron without any output


Jim_UK
06-14-2002, 08:44 AM
How can I ensure that absolutely no output is put anywhere from a cron task? I know that this can be acheived using /dev(??) something bits with lynx but what about curl?

Thanks :)

apollo
06-14-2002, 09:36 AM
You should redirect it to /dev/null

example:

30 * * * * /home/edatahost/rocks/go.pl >/dev/null 2>&1

enjoy ;)

Jim_UK
06-14-2002, 10:11 AM
Oh right, so /dev/null works for curl aswell?

If I have this do I just tack the /dev/null/ bit on the end?

5 * * * * curl /path/to/script.php

Thanks apollo :)

ffeingol
06-14-2002, 10:52 AM
Yep, /dev/null is the bit bucket in *nix. Things that goe there just disappear.

In *nix terms 1 is standard output and 2 is standard error (the are the numbers for the standard file handles). So the "2>&1" bit says to redirect the standard error to the same place that you are redirecting standard out (i.e. /dev/null).

Frank

Jim_UK
06-14-2002, 11:12 AM
Excellent... cheers :)

apollo
06-14-2002, 04:27 PM
You're welcome :)

Jim_UK
06-16-2002, 02:57 PM
Hi again,

I got the cron setup using curl but I'm trying to protect the directory with the php scripts in. I'm using htaccess but the cron won't run.

Any suggestions? I thought that the crons should still run file when the dir is protected with htaccess.

The cron involves, 'including' a file from a different dir, a few port scans then writing to a text file in a different dir.