-
Hi Gurus,
I created a simple shell script (named cleanup @ /usr dir). It deletes old files in a directory at selected times. Please see the following:
#!/bin/sh
cp /dev/null /var/adm/wtmpx
cp /dev/null /var/cron/olog
rm /var/adm/messages.0
rm /var/adm/messages.1
rm /var/adm/messages.2
rm /var/log/syslog.0
rm /var/log/syslog.1
rm /var/log/syslog.2
rm /var/log/syslog.3
I can run it successfully by using sh command. However, I tried to cron it and i got the following error:
-----------beginning of error message ---------------------------------------
From oracle Thu Aug 2 08:16:00 2001
Received: (from oracle@localhost)
by prod_sun(8.8.8+Sun/8.8.8)
for oracle; Thu, 2 Aug 2001 08:16:00 -0700 (PDT)
Date: Thu, 2 Aug 2001 08:16:00 -0700 (PDT)
From: oracle
Message-Id: <200108021516@prod-sun>
To: oracle
Subject: Output from "cron" command
Content-Type: text
Content-Length: 129
Your "cron" job on awp-sun
/usr/deltrc
produced the following output:
sh: /usr/cleanup: cannot execute
-----------end of error message -----------------------------------
the cron command line is
0,15,30,45 * * * * /usr/cleanup.
This is my first time to create a cronjob from scratch. Please advise me if i missed or made any mistake. It would be appreciated very much.
oracle 7.1.4 Unix os.
Thanks,
JN :(
-
If you mean that you can execute the "cleanup" script as follows:
$ sh cleanup
then execute the following command and it should run from the cron
$ chmod 755 cleanup
(it basically does not have execute perms)
-amar
-
Is the owner of the cron job running your script the same owner of the file?
This sometimes can cause issues if they are not.
Good Luck
-
It maybe help if you add the environment variant (.profile) to your cronfile.
HTH
-mike
-
Yes, this looks like a permissions problem. Make sure you have execute permission on the /usr/cleanup script.
ls -l /usr/cleanup should have something like:
-rwxr-xr-x /usr/cleanup
-
Thanks millions, guys. It works after i did the chmod 755 ...
:)