Operating System - HP-UX
1832916 Members
2852 Online
110048 Solutions
New Discussion

Re: cron job not finding files

 
SOLVED
Go to solution
Ian McClement_1
Occasional Advisor

cron job not finding files

Hi
I wonder if someone can suggest a theory to small but annoying problem I am having....

I have a cron job that creates a number of files and then at the end attempts to move some of the files that have been created but gives the following (output from elm with debug on):

mv /opt/unikix/rurdev/usertran.${yymmdd}*.* /shared/stats
+ mv /opt/unikix/rurdev/usertran.020513*.* /shared/stats
mv: /opt/unikix/rurdev/usertran.020513*.*: cannot access: No such file or direct
ory

but I can do an ll of them quite happily (as the same user):

$ ll /opt/unikix/rurdev/usertran.020513*.*
-rw-r--r-- 1 batch unikix 136180 May 14 07:37 /opt/unikix/rurdev/use
rtran.020513.05.13.08.10
-rw-r--r-- 1 batch unikix 284596 May 14 07:37 /opt/unikix/rurdev/use
rtran.020513.05.13.10.120
-rw-r--r-- 1 batch unikix 137389 May 14 07:38 /opt/unikix/rurdev/use
rtran.020513.05.13.12.140
-rw-r--r-- 1 batch unikix 258479 May 14 07:38 /opt/unikix/rurdev/use
rtran.020513.05.13.14.160
-rw-r--r-- 1 batch unikix 189326 May 14 07:39 /opt/unikix/rurdev/use
rtran.020513.05.13.16.180
-rw-r--r-- 1 batch unikix 189326 May 14 07:39 /opt/unikix/rurdev/use
rtran.020513.05.13.18.195

and can then move them manually.
I have checked the time stamps and they do exist at this point, permissions look OK.......
so can anyone suggest what the problem might be??

Any help greatly appreciated

Cheers
Ian
5 REPLIES 5
steven Burgess_2
Honored Contributor

Re: cron job not finding files

Hi

Nothing obvious

Have you tried

mv /opt/unikix/rurdev/usertran.020513*

as opposed to

mv /opt/unikix/rurdev/usertran.020513*.*

Steve
take your time and think things through
Steven Sim Kok Leong
Honored Contributor
Solution

Re: cron job not finding files

Hi,

Check your environment settings in your cron job.

You can force an expansion of * using the following in the front of your cron script:

set +f

Hope this helps. Regards.

Steven Sim Kok Leong
John Strang
Regular Advisor

Re: cron job not finding files

Hi Ian,

Just a thought - could it be that the script contains hidden characters in the line

mv /opt/unikix/rurdev/usertran.${yymmdd}*.* /shared/stats

which would prevent the files being found?

John
If you never make a mistake you'll never make anything.
Deepak Extross
Honored Contributor

Re: cron job not finding files

Looks like file globbing is not on when the cron job runs. Your .profile probably contains a "set +f", which is why the "ls" works fine.
But the cron daemon will not source your .profile before invoking the job, so you'll have to explicitly do a "set +f" or source your .profile in your cron job command.
Paula J Frazer-Campbell
Honored Contributor

Re: cron job not finding files

Hi Ian

Works as user !!!

Not in Cron !!!


Then has to be environmental variable.

Check the users .profile, there is somthing missed.

As already said set +f looks to be the reason.

Paula
If you can spell SysAdmin then you is one - anon