# How to create multiple directory after the directory name of current date-time?

I want to create backup directory at the name of current date and time so i use below method in my init file.

 $time=generate('/bin/date', '+%d%b%y_%H-%M-%S'),  i can able to create the directory named${time}.But i want to create multiple directory after the ${time} so that  class currentgen::backup::backup_folder inherits currentgen{ exec{"backup folder": path=>["/bin"], cwd=>"${prodequ_backup_path}",
command=>"mkdir -p ${time}/servar/default/deploy", } }  After executing this i got error like  Error: sh: line 1: /servar/default/deploy: No such file or directory Error: /Stage[main]/Currentgen::Backup::Backup_folder/Exec[backup folder]/returns: change from notrun to 0 failed: sh: line 1: /servar/default/deploy: No such file or directory  But this creates${time} directory but sub directories of ${time} not created. edit retag close merge delete ## 2 Answers Sort by » oldest newest most voted Do you mean that you have another resource that creates the top-level directory named for the value stored in the $time variable? If so, make sure that your exec resource includes a dependency on that other resource (likely a file resource) so it is applied first.

You have to make sure that all parent directories are in place before attempting to create subdirectories under them.

more

yeah i included that top level directory where i declare variable $time. ( 2016-02-11 23:36:07 -0600 )edit I changed my code like below it creates subdirectories under${time} , but the result of this execution i got filenamewith"?". i want only the file name with out "?".

                class currentgen::backup::backup_folder
inherits currentgen{
exec{"backup folder":
path=>["/bin"],
cwd=>"${prodequ_backup_path}", command=>"mkdir -p '${time}/server/default/deploy'",
}
}


result:

          12Feb16_11-02-35?/server/default/deploy

more