Tag Info

Hot answers tagged

6

take a look at rdiff-backup. it will not keep replicas of unchanged files, just the 'diffs'. if you want to keep on copying - use rsync rather than cp and take a look at syntax of exclude directive eg as described here. do remember to verify if your backups work [especially with rdiff or any other 'advanced' backup - verify the repository, try restore ...


5

You can't do this with a simple alias because the shell interprets the $@ when you define the alias. I would do this with a function in my .bashrc tkdiff () { /usr/bin/tkdiff $@ & }


5

If possible, setting up automount ( autofs ) would be the standard way to do this. It might already be in your distribution (comes with CentOS / Redhat default install ). Here is a tutorial. Why use Automount? Automounting is the process where mounting and unmounting of certain filesystems is done automatically by a daemon. If the filesystem is ...


4

Braces are used for parameter expansion (${foo%123}), brace expansion in either alternate ({foo,bar}) or sequence forms ({1..25}), or in blocks of code ({ foo ; bar ; }). Square brackets are used as comparison commmands ([ "$foo" -lt 3 ], [[ $bar =~ ^123 ]]), As a range or character class in a glob (ba[rz], foo[[:alnum:]], qu[[=u=]]x), as part of an array ...


3

http://ss64.com/bash/syntax-brackets.html


3

If you know the list of possible extensions, you can do: process ${path}{,.Z,.Z,.gz}


3

Can you grep /etc/mtab for the device? grep -c '/mnt/foo' /etc/mtab if grep outputs '1' then /mnt/foo is mounted.


3

First rule of cron is to set up several things you expect. One, what directory you are in (explicitly 'cd' to it). Two, the path you expect (in the crontab, PATH=...) and three, where the mail goes (if you want to change it.) For example: SHELL=/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin HOME=/var/log I would then also have each script either set up ...


3

CRON does have its own environment. Did you install the job with crontab -e as the user running the job? How was the job added? Also, a little re-do of the script, with looping; this should work OK on your setup. #!/bin/sh ### internal variable definitions dvar=`date +"%m\/%d\/%y"` filedate=`date +%b%d%Y` # add the prefix of new hosts into the string ...


2

Use mountpoint. mountpoint -q /path/to/nfs/share || mount -t nfs server:/nfs/share /path/to/nfs/share (I don't know how widespread or portable mountpoint is; it's provided by the initscripts package on my Debian server.)


2

In solaris If your checking that the system where the script is running has a remote filesystem mounted then ISMOUNTED=`/usr/sbin/mount | grep "^/path/to/mount "` if [ "$ISMOUNTED" = "" ] then mountcommand* fi *mountcommand could be /usr/sbin/mount /path/to/mount if there is a corresponding entry in the /etc/vfstab or /usr/sbin/mount ...


2

In Linux you have always the option of using the good ole tar, using --exclude or --exclude-from options


2

The problem in your script is that (with the shell you're using) in a pipeline, each command runs in a separate subshell, and none of their statuses is propagated to the parent process. So after command1 | command2, $? is always 0. Even if you fixed it, your script is highly unreliable: it will match processes with a name that contains your process as a ...


1

@Redmumba is on the right path here. If you try to add iptables rules for interfaces that aren't configured/up yet, then iptables will throw an error and the rules doesn't get added. This sounds to me like you are configuring at least one of your interfaces through NetworkManager or something similar (depends on your distro) and that part only happens when ...


1

You don't mention the brand of your NAS device. Some higher-end NAS appliances (Netapp, Isalon, DataDomain) support deduplication. This would allow you to do full daily backup, and any data would be 'deduplicated' on the appliance. This deduplication/compression is completely transparent to the user (/home/user/myimages/fooimage.tiff looks exactly the same ...


1

If you want to stick with a full backup every day strategy, you can use rsync with some --exclude flags to copy only non-image data. If you wanted to further reduce the size of your backups, you could compress the backup copies; the quickest and easiest way to do that would be to use tar to make the archive (so the output would be a single file) with -z or ...


1

If you could deal with /usr/share/man/man1, then you could do dirname /usr/share/man/man1/bmtoa.1.gz, but since you stated that you need the man1 to also come off, so you'll have to daisy-chain them: dirname `dirname /usr/share/man1/bmtoa.1.gz`


1

this will work ${path%/*/*}, but works from the back to the front. here is a good how-to for chopping strings in bash.


1

In addition to ~/.profile, they are defined (first) in /etc/profile. See the sh (1) man page. Which particular variables are you asking about?


1

Try looking in /etc/profile and /etc/default/login on Solaris. Some values may be built-in defaults or picked up from the environment, such as LOGNAME or HOSTNAME.


1

You can still do the globbing in Bourne Shell for f in ${given-path}*; do process $f done It's a good idea to do as much of your shell scripting as possible limiting to Bourne shell syntax; that maximizes portability. In many cases, it also improves speed.


1

I believe Christian is on the right track. If you are certain of at least a portion of your path, using Bash's builtin globbing will yield any files matching your pattern. For example, I have a function in my .profile which I frequently use to cat gzipped and plain-text log files: function mscat { is_gzip="\.gz$" for file in $@; do if [[ "$file" ...


1

Just to throw another idea out there, the df command can tell you the mounted filesystem of a directory. If you throw in the -l option, you get a pretty easy test to see if a directory is on a local filesystem or not. $ cd /net/remoteshare $ df -l . df: no file systems processed $ echo $? 1


1

When it comes down to it, shell programming is about plugging together small discrete tools using pipes to produce some kind of compound utility. A utility that did what you're asking for in a "smart" way wouldn't really match the Unix philosophy. If you want to do it more intelligently, you might want to look at doing this in Perl or Python or C, where ...


1

You may be able to do something with stat. The "device" field will be different across different filesystems. So, assuming you want to see if /mnt/foo is mounted, you'd compare the output of stat -c%d /mnt/ to stat -c%d /mnt/foo/. If the device is different, something is mounted there. if [ `stat -c%d /mnt/` -eq `stat -c%d /mnt/foo/` ]; then mount ...



Only top voted, non community-wiki answers of a minimum length are eligible