[Discuss] Bash question
John Blomfield
jabfield at shaw.ca
Sun Aug 17 09:44:47 PDT 2014
Thanks Noel and Andrew for your suggested code. Unfortunately, both your
suggestions are a little beyond my comfort level when it comes to bash
scripts and I have decided to use the following approach:
if [ -n "$1" ]
# Test whether command-line argument is present (non-empty).
then
..........use these rsync options
else
...........use these rsync options
fi
That lets me view the output or redirect it to log files (but not both).
However I don't really need to have both just one or the other will do
fine. I will run the cron job with no argument and then run it with an
argument from a terminal when required.
Actually, the script already includes a few Kdialog GUI popup messages
reminding me to plug a USB backup drive, when errors occur and when its
finished successfully, so on a miserable winter day when I am looking
for a project I plan to re-write the whole thing as a Python script or
as a Qt4/C++ GUI with a KDE4 Plasma panel notifier and if I get really
bored I will add a Gnome notifier, which should work in Cinnamon. I
really do need to keep my old brain active as I have written little code
of late.
John
On 08/16/2014 11:36 PM, Noel Burton-Krahn wrote:
> Hi John,
>
> I use 'tail -f' to save the output of a program and watch it at the
> same time:
>
> make >make.out 2>&1 & tail -F make.log
>
>
> Note, Ctrl-C will kill tail, not the make session above. You have to
> kill make explicitly if you want to stop it:
>
> kill %-
>
>
>
> Sometimes you make want to start a long running program and be able to
> log in from time to time to see how it's doing. I start it in a
> screen session:
>
> screen -d -m -S myscreen tcpdump -veplni host
>
>
> Then later while it's running I can log in from a different session
> and check up on it
>
> screen -dr myscreen
>
> Or kill it:
>
> screen -X -S myscreen quit
>
>
> HTH
> --
> Noel
>
>
> On Fri, Aug 15, 2014 at 3:24 PM, John Blomfield <jabfield at shaw.ca
> <mailto:jabfield at shaw.ca>> wrote:
>
> Here is a snippet from a bash script cron job I run:
>
> .............
> if rsync -avz --delete --exclude=lost+found $SOURCEDIR $DESTDIR 1>
> $DEBUGLOG 2> $ERRORLOG; then \
> ..........
>
> Occasionally, I need to run this script manually in a terminal and
> would like to see the output in the terminal as well as saving it
> to the debug and error log files. Any suggestions?
>
> --
> John Blomfield
> Delivered by Thunderbird Email on Linux OpenSuse-KDE4
>
> Old John B's Linux Notes http://www.oldjohnbslinux.wordpress.com
>
>
> _______________________________________________
> Discuss mailing list
> Discuss at vlug.org <mailto:Discuss at vlug.org>
> http://lists.vlug.org/mailman/listinfo/discuss
>
>
--
John Blomfield
Delivered by Thunderbird Email on Linux OpenSuse-KDE4
Old John B's Linux Notes http://www.oldjohnbslinux.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://vlug.org/pipermail/discuss_vlug.org/attachments/20140817/92cdc20c/attachment.html>
More information about the Discuss
mailing list