My problem can be summed up by making this simple command works :
nice -n 10 "ls|xargs -I% echo \"%\""
Which fails :
nice: ls|xargs -I% echo "%": No such file or directory
Removing the quotes makes it works, but my point is to wrap multiple quoted commands into one to do something more complex like :
ftphost="192.168.1.1"
dirinputtopush="/tmp/archivedir/"
ftpoutputdir="mydir/"
nice -n 19 ls $dirinputtopush | xargs -I% "lftp $ftphost -e \"mirror -R $dirinputtopush% $ftpoutputdirrecent ;quit\"; sleep 10"
Try using
nice -n 10 bash -c 'your; commands | or_complex pipelines'as command. This waybashis the binary and the string after-ccontains a sequence interpreted bybashso it can contain pipelines, loops etc. Watch out for proper quoting. You need to do it this way becauseniceexpects a binary, not expressions interpreted by the shell. In contrast, shell builtins such astime(but not/usr/bin/timewhich is a separate binary) will accept shell expressions as the command to execute. They can because they’re built into the shell.niceis not, so it requires a binary to execute.