cancel
Showing results for 
Search instead for 
Did you mean: 

Crontab problem

Crontab problem

Hi,

I trying to include a script in my crontab as user. I used "crontab -e" to include my script there but does not seem to work.

15 08 * * * /tmp/test

If I understand correctly it is set to run at 08:15 every day, correct?

Can anybody identify any error?
10 REPLIES
Steven Schweda
Honored Contributor

Re: Crontab problem

> [...] does not seem to work.

What, exactly, does that mean? No
"/tmp/sample1" file created, or what?

> [...] correct?

Looks ok to me (which does not prove much).

ls -l /tmp/test

This works interactively?:

/tmp/test

"/tmp" is not where I'd put a script which I
intended to run every day.


Around here:

dyi # date ; ls -l /tmp/samp*
Fri Mar 19 17:56:12 CDT 2010
-rwxr-xr-x 1 sms users 65 Mar 19 17:54 /tmp/sample
-rw-r--r-- 1 sms users 11 Mar 19 17:56 /tmp/sample1

dyi $ crontab -l
56 17 * * * /tmp/sample

dyi $ cat /tmp/sample
#!/usr/bin/sh
#This is a sample
echo " Sample 01" > /tmp/sample1


dyi $ uname -a
HP-UX dyi B.11.31 U ia64 4235313755 unlimited-user license

Is your OS a secret?

Re: Crontab problem

Hi there.

# uname -a
HP-UX pruebas B.11.31 U ia64 3246142436 unlimited-user license
# ps -ef | grep cron
root 1777 1 0 Feb 18 ? 1:58 /usr/sbin/cron
# date
Fri Mar 19 17:14:03 MXST 2010
# crontab -l
15 17 * * * /tmp/test
$ date
Fri Mar 19 17:15:10 MXST 2010
# cd /tmp
# pwd
/tmp
# ll sample*
sample* not found

As you can see the cron is running but it does not execute the script.

Any suggestion?

Regards.
Raj D.
Honored Contributor

Re: Crontab problem

Damian,

You can do a test from the user you are trying to run the cron.

- Also check if the user is permitted to use cron, in cron.allow user entry should be there.

Check with executing from command prompt:
$ ls -l /tmp/test #Make sure it is executable.

$ /tmp/test

$ ls -l /tmp/sample*

If this work , cron supposed to work at the given time.


Hth,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Steven Schweda
Honored Contributor

Re: Crontab problem

> As you can see the cron is running but it
> does not execute the script.

Can _you_ execute it?

> ls -l /tmp/test

> /tmp/test

> $ ls -l /tmp/test #Make sure it is executable.
>
> $ /tmp/test

Still wondering...

Re: Crontab problem

Hi Raj D.

The script has exec. permissions
I executed the script and this is the out:

$ whoami
dsarmien
$ pwd
/tmp
$ ll test
-rwx------ 1 dsarmien users 65 Mar 19 09:57 test
$ cat test
#!/usr/bin/sh
#This is a sample
echo " Sample 01" > /tmp/sample1
$ ll sample1
sample1 not found
$ ./test
$ ll sample1
-rw-r--r-- 1 dsarmien users 11 Mar 19 18:05 sample1
$ cat sample1
Sample 01


The user dsarmien is permitted to use cron:

$ cat /var/adm/cron/cron.allow
root
dsarmien
$ crontab -l
15 17 * * * /tmp/test
$ whoami
dsarmien

Thanks for your attention.

DASM

Re: Crontab problem

Hi Steven.

Yes, I can execute the script.

$ ll test
-rwx------ 1 dsarmien users 65 Mar 19 09:57 test

Regards.
Dennis Handly
Acclaimed Contributor

Re: Crontab problem

Have you looked at the log?
/var/adm/cron/log

Note: test is a bad name for a script since it conflicts with the shell builtin. But since you use an absolute path, it should work for you.
Kapil Jha
Honored Contributor

Re: Crontab problem

just to make sure if its working incrase the frequency for the script, and check the logs suugested by Dennis, it would tell you wheather cron is actually running the script or now.

you can also try
sh /tmp/test in cron script.

Although urs things is right.

BR,
Kapil+
I am in this small bowl, I wane see the real world......

Re: Crontab problem

Hi.

I only restarted the server and after that it worked correctly.
It was weird because I know it was not necessary to restart in order the cron executes the script.
There were no incidents in the log of the cron.

Thanks to all for answering.

Regards.

Re: Crontab problem

Solved.

Thanks.