On Tuesday September 1 2009, James D. Parra wrote:
Hello,
I have a mail server that creates back dir's with the creation date as part of the dir name. For example; full-20090901.080010.175/. I'd like to create a cron job that can tar the dir with a .tgz extension and retain the dir name in the resulting tar file. For example, full-20090901.080010.175.tgz. The dir name will change daily.
For starters, .tar.gz is the preferred way to name gzip-compressed TAR archives.
I have the following commands to get the dir name, but getting that name into a tar file and having a good tar file created is not working.
What I have so far;
find -maxdepth 1 -type d -mtime -1 [this gets the dir name] -exec tar czf {}.tgz {} \;
What do you mean by "[this gets the dir name]"? As ever with scripts of this sort, it's advisable to quote variables and placeholders (like the {}) so that special characters don't mess up the interpretation of the command.
The squiggly brackets {} contain the dir name, but the tarball creation isn't working.
Be specific about what "isn't working." Are ensuring that you're executing the command in the proper directory? Are you running this as root or another user? Are you getting mail from cron describing a failure?
Any hints on creating a cronjob script that can tarball a dir whose name will change on a daily basis and have the resulting tar file retain the name of the original dir name?
One generic hint is to put only a simple command name in your crontab and do all the real work in that script. Set the PATH and MAILTO variables, too.
Many thanks in advance,
James
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org