LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (http://www.linuxquestions.org/questions/red-hat-31/)
-   -   Using Cron (http://www.linuxquestions.org/questions/red-hat-31/using-cron-578690/)

Blazeix 08-21-2007 10:18 AM

Using Cron
 
Hi, I have an account on a RedHat 4 server. I would like to have a cron job run at a certain time. In order to test it I made a simple script called cronTest.sh:
Code:

$ cat cronTest.sh
#!/bin/bash
touch /path/to/my/account/testpad/testComplete
touch /path/to/my/account/testpad/testCompleteAgain
touch /path/to/my/account/testpad/testComplete3

I put the following entry in crontab:
Code:

$ crontab -l
50 9 * * * /path/to/my/account/testpad/cronTest.sh

So, cronTest.sh should run at 9:50 every morning, and create three empty files in the 'testpad' directory. Unfortunately, at 9:50 I got the following system mail:

Code:

X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/path/to/my/account>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=username>
X-Cron-Env: <USER=username>

/bin/sh: /path/to/my/account/testpad/cronTest.sh: Permission denied

Permissions of the testpad directory:
Code:

drwxrwxrwx  2 username games 2048 Aug 21 09:48 testpad
Permissions of cronTest.sh
Code:

-rwxrwxrwx  1 username games 228 Aug 21 09:34 cronTest.sh
Does anyone know what's going on? Is it something on my part, or should I contact my sysadmin? Thanks for any help!

MensaWater 08-21-2007 11:07 AM

What are the permissions on "/path/to/my/account/testpad" directory?

Were you logged in as the same "username" that owns the file when you executed your "crontab -e" to add the entry?

Check to make sure the file in /var/spool/cron/crontabs that contains the entry is named for the "username" you expect it to run as.

Blazeix 08-21-2007 11:15 AM

Quote:

Originally Posted by jlightner (Post 2865856)
What are the permissions on "/path/to/my/account/testpad" directory?

Hi, the permissions to the testpad directory are in my first post (2nd from the bottom). The permissions are 777.

Quote:

Originally Posted by jlightner (Post 2865856)
Were you logged in as the same "username" that owns the file when you executed your "crontab -e" to add the entry?

I believe so. I only have one account on this system. When I am logged in to my account and execute 'crontab -l', I see the 'cronTest.sh' cronjob from my first post. Also, I set the permissions of cronTest.sh to 777, so anybody should be able to run it.

Quote:

Originally Posted by jlightner (Post 2865856)
Check to make sure the file in /var/spool/cron/crontabs that contains the entry is named for the "username" you expect it to run as.

Unfortunately, I get a permission denied error when I try to do this.
$ cat /var/spool/cron/crontabs
cat: /var/spool/cron/crontabs: Permission denied

I don't have root access to this machine. Thanks for your help.

MensaWater 08-21-2007 12:29 PM

It could be an issue with /etc/cron.deny or /etc/cron.allow. Those files determine who can and can not use cron.

I'm afraid you'll have to have your systems admin look into this. the rwxrwxrwx means everyone can read, write and execute so the permission issue isn't on your directory or file.


All times are GMT -5. The time now is 11:37 PM.