[CentOS] cron job not working

Al Sparks data345 at yahoo.com
Wed Sep 17 00:00:42 UTC 2008


Here's a perl script that works when I run it manually.  But when I
run it via cron, it won't create the directory.  But worse than that,
an email isn't sent to the account running the job.  So I'm not
getting an error, but it does work when I run it manually.

If I put an obvious error in the script, cron does generate an
email giving me the STDERR.

What could it be?
    === Al

#!/usr/bin/perl

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

# Above functions, "time" and "localtime", return weird $year and $month
# Need to be converted to become human readable

$year = $year + 1900;
$mon = $mon + 1;

# Want $mday and $mon to be 2 digits, with leading zero if necessary

$mday = "0" . $mday if $mday < 10;
$mon = "0" . $mon if $mon < 10;

# Second parameter is mask in octal

chdir "/ora-local/db-test-backups";
mkdir "${year}_${mon}_${mday}", \00022;
####End perl script



More information about the CentOS mailing list