Issue with touch command

Hi,

I have a touch command in my script which creates / updates a file TODAY. Then i try to find the list of files which are newer than this TODAY file.

touch `date '+%m%d'`0000 TODAY
cd /auto/users-35/p494856/learning/filetransfer/
find . -name "*csv" -newer /auto/users-35/p494856/learning/scripts/TODAY -exec ls -ltr {} \; > temp.txt

This script is working fine when I execute it manually through prompt.

arun's dev >sh check_list.sh

But when I try to execute this script using a cron job, it is not working.

Here is what i mentioned in the cron.txt

53 5 * * 1-5 /auto/users-35/p494856/learning/scripts/cash_ladder_check_list.sh

Then i gave crontab cron.txt..

When the job is executed, I couldnt see the TODAY file updated...

Could someone help me out in this?

Regards
Arun

Have you written following line at the begining of your script :

#!/usr/bin/sh

Also add the exect full path to "TODAY" :

touch `date '+%m%d'`/auto/users-35/p494856/learning/scripts/TODAY

If yes the post the exect script...

:b:

Hi,

Here is the script-

 

#! /bin/sh

touch `date '+%m%d'`0000 TODAY
cd /auto/users-35/p494856/learning/filetransfer/
find . -name "*csv" -newer /auto/users-35/p494856/learning/scripts/TODAY -exec ls -ltr {} \; > temp.txt

The above script is placed under the path /auto/users-35/p494856/learning/scripts/

Regards
Arun

---------- Post updated at 06:58 AM ---------- Previous update was at 06:34 AM ----------

Hi,

You are right... I added the path name for the TODAY file in the script.

Its working fine now...

Thanks
Arun

Hi Arun,
It is a good practice to always use full path name for file ordirectory, when you want the script to be run by cron....:D:D

Because cron daemon starts the script in the home directory of root.
Suppose root is having home directory "/root".Then your script will be started as :

/root# /bin/sh /path/of/the/script     ---->>> WHERE /root IS THE WORKING DIRECTORY FOR CRON DAEMON.

:b::b: