Calling all scripters...

jarednichols
Honored Contributor

Hi-

Need a quick hand… I'd like to re-direct all my output from a script to a log file. Easy enough with an "exec &> <filename>" at the top of my script. However, I get no date/timestamp when I do this in the log file. I'd like it to look all purdy like system.log or jamf.log does, but don't know how to accomplish that.

Anyone?

Thanks!
--
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

4 REPLIES 4

tlarkin
Honored Contributor

You could write a small function that goes through output settings
along with a date stamp and then use it at the top of your script.

jarednichols
Honored Contributor

I think I've kinda figured it out, but am hammering through it… Deals with modifying /etc/syslog.conf to catch messages generated by my launchd controlled script. I'll let y'all know if I get it sorted.

j
--
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

Not applicable

you can do something like this at the beginning of each script or action:

echo "[$(date '+%Y%m%d.%H%M')]" >> /path/to/log

jorge a. najera-ordonez

jarednichols
Honored Contributor

Yeah I've got that already… It works but… Meh. I'd like to use the built-in logging functionality of the OS so that I get nice pretty log files with timestamps and if they get big enough, rolled up and cycled down.

j
--
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436