mac terminal login costs too much time - macos

Every time I open a new terminal it costs about 3-5 seconds to login , plz see the screenshot.

Terminal seems to save every command to ASL (Apple System Log) log files and it can become cumbersome. Many reports that deleting ASL log files speed up the Terminal. Try:
sudo rm /private/var/log/asl/*.asl
and relaunch Terminal.

Related

Run my Mac command "chsh -s /usr/local/bin/false" and can't log in to my account again

I really messed up!
Since I ran my Mac with the command below
chsh -s /usr/local/bin/false
Several minutes later, I noticed my Mac logged out by itself.
So, I tried to log back in by clicking 'change user'
But I can't see my administer account there.
I guess 'false' is not a loggin-able shell, that's why my account is hidden.
I'm trying to change my shell with Terminal.app on recovery mode or single-user-mode (but both are read-only).
So right now, I want to know if there's any solutions that might be able to fix this problem.

Export/Stream Mac Terminal Output To File

I am running a php script on my Mac terminal which takes hours and hours to run. It consumes memory very quickly, and after a while the scroll back gets truncated. Settings on the Terminal: Scrollback - Limit to available memory.
Is there a way to automatically stream (or just save) the output into a file (whether on local disk or on external harddrive). Also I realise the memory doesn't get cleared until I restart my com (my Finder indicates 0 space on my harddrive after a while but when I restart my com it becomes 20GB). Is there a way to clear this once my output is saved?
It will be nice to include the timestamp as well in the file.
Run your PHP script in the background (or even with nohup as well, if you want to be able to log out and leave it running), and save your output to a log file on disk like this:
someScript.php > log.txt &
Now, if you want to watch the log file growing at a later point, just use the -f option to tail to follow the log:
tail -f log.txt
If you see that all is well and the job is still running, press CTRL+C and you will stop following it but the job will continue. If you want another look later, just run tail again.
If you want to see if your script has passed, say "PHASE 2", just grep for that in the log file:
grep "PHASE 2" log.txt
If you want to timestamp the lines, I would suggest you use the ts utility which is part of moreutils, so hoping you use homebrew to manage packages (as any sensible Mac user does), you would install it with:
brew install moreutils
Then you could do:
someScript.php | ts > log.txt &

mac osx cant find cronjob which opens safari every few seconds

I´ve installed a cronjob under mac osx which opens/curl an URL. Everything works fine but now I deleted all cronjobs by
crontab -r
and I deleted all lines in the crontab and
crontab -l
does not deliver any entry. The problem is that safari still opens every few seconds. Its also blocks my reboot command. I have to shut it down manually then I can restart my mac. When I get my login screen where I can click my User-Button the mac does a short "flash". So the screen gets white for one short moment. Looks like if you do an screenshot on an Iphone. Safari opens itself on startup (There is no entry in the startupitem list) to execute the Url. Somehow it feels as if there is a cronjob running in the backround but I cannot find it! Thanks.
Try running this script to see if you can spot the curl process being run, then you can find its Parent Process Id (PPID) in column 3, and then see the PID of the calling process. That will tell you how it is getting launched - or by whom, at least.
while :; do ps -aef | egrep "UID|curl" ; sleep 1; done
Ok, I found a solution. I had a .plist in /Library/LaunchAgents calling my URL. I deleted it, remove from trash and restared computer. No it´s gone. Yes.

How to share the screen output of a running process?

I have a program that will run for a long time , This program edit and run in remote server .I use
the computer in office to remote connect the server and run it . The progress shows on the computer screen of the computer in my office ...
I want to see the output in my home , How can I capture the output which is on the screen of computer in office and see the result at home?
I think about writing the output to a file , but I need to close the file . So I should open file then write output , close .. open again?
thanks
I don't know the proper tag should use , but the program is written in perl .....
you can tee it
your_program.pl | tee logfile.txt
and see the lastest result in logfile.txt at home with
tail -f logfile.txt
Why not just redirect to a log file and tail it (or load it in an editor etc.) ?
$ myprog.pl >/tmp/logfile 2>&1
The above redirects your output to a log file (/tmp/logfile - you may wish to choose a better location since /tmp is temporary and can be trashed during a reboot) and redirects stdout/stderr to the same place. Note that this captures the output of your program and you don't need to modify your script.
An alternative is to run your program within screen
Perhaps one of the most useful features is that you can re-connect to
your sessions after you log out, move to another computer, or get
disconnected, and continue working as if nothing happened. All your
edit sessions, shell windows, etc. will be there just as you left
them.
Personally, I use screen for this sort of thing.
Connect to the server
Enter the command screen. It displays a nice message stating the version of screen and that it's under the GPL.
Run the actual command.
At any time, hit ctrl-A, D to disconnect from the screen session. You'll see a message along the lines of [detached from pid.tty.server]. Log out from the server normally.
Connect to the server again and enter the command screen -x to reconnect to your session.

Terminal app in Mac OS X Lion 10.7 stuck?

Some days ago I tried to create a shell script which would open all the torrents files in my downloads folder. I am not sure if I get the sh file written right, since then I am getting this message:
Last login: Fri May 18 22:54:28 on ttys000
LSOpenURLsWithRole() failed for the application /Users/Alex/Downloads/(Demonoid.me)-Adobe_Master_Collection_CS5_(OS_X)__12302562.8934.torrent
with error -10810 for the files
/Users/Alex/Downloads/Coda_1_6_2_[_Plist]_[Serial]_O-Demonoid.me-O_12302562.8934.torrent,
/Users/Alex/Downloads/Coda_1_7_3_[k'd]-((Demonoid.me))_12302562.8934.torrent,
/Users/Alex/Downloads/[kat.ph]grid.systems.in.graphic.design.josef.muller.brockmann.torrent,
and /Users/Alex/Downloads/[kat.ph]pixie.lott.cry.me.out.mp3.housezz.torrent.
job done
/bin/bash: line 8: end: command not found
[Process completed]
And I can't do anything in Terminal. I don't know what to do. Any insights about it?
Open a terminal and let it hang.
Open the terminal preferences menu (Command-comma).
In the Startup tab, remember your current shell setting.
Choose a shell other than Bash or Sh (e.g. /bin/tcsh — this is a desparation measure, and only temporary).
Close the locked terminal.
Open a new terrminal (Command-N).
That should give you a command prompt.
In that window, edit your .profile or .bashrc or whatever you added the Torrent lines to.
Remove the Torrent-related lines.
Go back to terminal preferences.
Reset the shell to /bin/bash.
Try opening a terminal window once more.
When it comes to trying to add the Torrents again, write a shell script. Debug it. Only put it in your profile when you're sure it is correct, stable, reliable, and doesn't lock your terminal. Then test it with a terminal already open — opening a new terminal to do the test. You've then still got an unlocked terminal you can fix problems with.
If you have a graphical Vim (Gvim or MacVim), you may be able to launch that and then edit your .profile without having to tweak the Terminal preferences.

Resources