Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test File creation date?!?! 1

Status
Not open for further replies.

Scunningham99

Programmer
Sep 20, 2001
815
GB
Hi All

I have no experience in UNIX script. so please bear with me! Crontab uploads a file namely 'rcc1_gvc_sales.csv' every morning! this is reliant on the file being refreshed by another server every day, else same file is uploaded again. This is bad, so my aim is to code a check which checks the date of the file.

Ie. if the file creation date is NOT = to todays date then touch the file so it is blank, hence blank file is uploaded, meaning the same file has not being uploaded twice.

the problem i have got is i do not know the command to check creation date or somewat of file!!!!!


if [ rcc1_gvc_sales.csv != "todays date HELP" ]; then

touch rcc1_gvc_sales.csv #to make the file blank

fi;

ANY CLUES WOULD BE GREATLY APPRECIATED!!!
 
ls -c gives the creation date or time of last modification
You need to use this with -l or -n
 
touch filename doesn't make a file blank, it just updates the timestamp. If you want to blank out a file, do the following instead:

cat /dev/null > yourfilename

Hope this helps!
630111
 
scunningham99,

wouldn't rsync take care of all your needs? rsync checks the file to see if the date or size of a file is changed before it attempts to transfer it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top