Automatically save log files of terminal sessions

Joined
Jun 10, 2011
Messages
1
Reaction score
0
Points
1
Hi folks

Does anyone know whether there is a setting in Terminal that will automatically generate log files of all Terminal sessions and save them individually? I saw an allusion to this on a post somewhere but cannot find any such setting myself.

That failing, can anyone give me a hand implementing this solution I found on a dead forum? I am an extreme novice when it comes to this.

Use the script command. I've set up one of the macs here to log everything automatically every time the terminal is opened. Just save these two lines into a blank file:

#!/bin/bash
script "/Users/<yourname>/Documents/Logs/`date "+%m.%d.%y %H.%M.%S"`"

Then make it executable, put it somewhere like /usr/local/bin and set it as the command to execute when creating a new terminal window in Terminal preferences.

Specifically;
1) I have saved a text file with this content on my desktop but when I try to copy it to /usr/local/bin via Terminal (because I can't actually navigate there manually with Finder) I get a permissions denied error...
2) How would I then make it executable?
3) How would I set is as the command to execute when creating a new terminal window in Terminal preferences - I cannot see where/how to set this.

MUCH 'bliged.
 
Joined
Mar 1, 2013
Messages
2
Reaction score
0
Points
1
anyone?

Hi, I'm having the same doubt about this issue.
I'm running a program in terminal and want to same all the log.

Can anyone answer?

ps- i'm a newbie
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
You need to put the second line in .bashrc or .bash_profile. These may or may not be in your home folder.
If you don't have one, copy /etc/bashrc and/or /etc/profile to your user folder. Notice the periods in the first line. This makes the files hidden.
Edit the file, then rename it with the period. Be sure the files are in plain text, not .rtf.
If you need detailed instructions i can give it when I get off work at noon.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top