Eric at Lucii.org on 31 Aug 2011 08:52:31 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Bash I/O redirection


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Julien:

There is no way to inform the shell ->at the beginning of the line<- that it
will be redirecting stdout and/or stderr.

I have used this type of construct in my crontab (your times will, of course, vary):

1 12 * * * /home/elucas/bin/cronscript >> /home/elucas/log/cronscript.log 2>&1

That redirects stdout and stderr to append to the log file.

Yes, "ugly" cron.  How often do little children stop in the street, point to
you, and taunt "your crontab is ugly... your crontab is ugly"?
Why would you care?  They are just sysadmins^H^H^H^H^H^H^H^H^H^*children* after all!

Hope that helps... or at least gives you a laugh.

Eric

On 08/31/2011 11:33 AM, Julien Vehent wrote:
> Hey Guys,
> 
> I have this bash script that does an oracle backup (launched via crontab), and
> I'd like to redirect the output of the script to a file. The classic ways to do
> it would be:
>    * use a wrapper script (that requires an additional script...)
>    * call the script with '>' in the cron line (make my cron line ugly)
>    * inside the script, put a ">>" after each command (berk !)
> 
> My question is: would there be a way to put a global redirection at the
> beginning of the script ?
> something like
>    "1 > /tmp/log.txt"
> and then have all the subsequent commands go to the log file ?
> 
> 
> Thanks,
> Julien
> 
> ___________________________________________________________________________
> Philadelphia Linux Users Group         --        http://www.phillylinux.org
> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
> General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug
> 

- -- 
#  Eric Lucas
#
#                "Oh, I have slipped the surly bond of earth
#                 And danced the skies on laughter-silvered wings...
#                                        -- John Gillespie Magee Jr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5eWLAACgkQ2sGpvXQrZ/6X4ACg31pt3A/URi12ImRPp1zlSSvo
BpsAnRdnvNI3WgvTU9mDtxa693NAM6jM
=4gUK
-----END PGP SIGNATURE-----
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug