Link to home
Start Free TrialLog in
Avatar of toulon
toulon

asked on

to name a file after the date

in a cron script I want to name an output file after the date of the day in command line like :
ls > 'fileoftheday'.log

Could you tell me how I do that?
Thx.
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

This will create files with a name of YYYYMMDD.log, which is best for sorting by date order.

($day,$month,$year) = (localtime)[3..5];
$date_string = sprintf("%04d%02d%02d%s", $year+1900, $month+1, $day,'.log');

system("ls > $date_string");
Avatar of cadabra
cadabra

ls > `date '+%d%m%Y'`.log
ASKER CERTIFIED SOLUTION
Avatar of Kim Ryan
Kim Ryan
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial