Re: How to easily append a timestamp to tar archive name ?



Matthew Lincoln schrieb:
I would like to create a tar archive with the well known tar command

tar czvf "/usr/local/user234/bkp.tar.gz" /home/users/pmiller/

It works. However I would like to automatically append a timestamp whenever I call this command
in a (perl) script.

The created archive file name should look like

bkp-20071109-1523.tar.gz

Where the format is preferred as YYYYMMDD-HHMM

Does Gnu-tar offer such an automatic timestamp appending?

AFAIK no.

Assuming you are using a bash you could solve it by:

tar czvf "/usr/local/user234/bkp-$(date +%Y%m%d-%H%M).tar.gz" /home/users/pmiller/

It *should* also work when called from a perl script, but I didn't test it.


HTH Martin
.



Relevant Pages

  • Re: crontab script
    ... if it is off the perl script tries to connect again and lunch a perl ... get the timestamp. ...
    (comp.lang.perl.misc)
  • Re: How to easily append a timestamp to tar archive name ?
    ... However I would like to automatically append a timestamp whenever ... Does Gnu-tar offer such an automatic timestamp appending? ... Is there a work around (in perl) which let me create such ... The POSIX module supplies you with the strftimefunction. ...
    (comp.lang.perl.misc)
  • Re: How to easily append a timestamp to tar archive name ?
    ... However I would like to automatically append a timestamp ... The created archive file name should look like ... Does Gnu-tar offer such an automatic timestamp appending? ... Is there a work around (in perl) which let me create such ...
    (comp.lang.perl.misc)
  • Re: how to find the "yesterday" logfile name?
    ... could I do in perl? ... Precompute what the file's name should be, ... on the start date of the script. ... You'll get its OS timestamp and can calculate ...
    (comp.lang.perl.misc)
  • 2005-10-23 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)