Just wanted to share a very old article I stumbled upon a few day ago. It is a small into to GNU screen and can be found here http://www.linuxjournal.com/article/6340.
Like many other vannabe *unix natives I have being using screen on and off for different tasks, but not very efficiently. Basically I just used it to launch a process and then Ctrl-A+D to detach and get back later with screen -r. Just recently discovered that screen is a very power full tool for doing your every day work.
Now the first thing I do when opening my laptop is "still" to open Chrome but the second thing I do now is to type screen in my terminal and hence spawning windows within screen with all the stuff I need. But in order to work efficiently with screen you need to know the basics of navigating between windows, copy-paste and so forth. All this a more is covered very nicely in the article above.
Friday, November 15, 2013
Friday, September 20, 2013
Disk space not used, but not free. Where did it go...
I recently pulled out almost all of my hair, searching for lost disk space on a Ubuntu box.
"df" showed that almost all space on disk was used, but i was not able for find the files taking up all the space. Of course I went through all the usual suspects (http://ubuntuforums.org/showthread.php?t=1122670), but in the end cause was very simple and yet not obvious.
Side story; the box runs a installation of MySQL that had been mangled when trying to import a database from another box. The MySQL files had been deleted, but I forgot to shutdown the MySQL daemon. So all files used by MySQL was still held by MySQL. This led to disk space being used, but not found when searching for files. the trick to discover the used space was the following:
lsof | grep "deleted"
I know it is a obvious error, but I use a few hours to find this.So heres the tip for you.
"df" showed that almost all space on disk was used, but i was not able for find the files taking up all the space. Of course I went through all the usual suspects (http://ubuntuforums.org/showthread.php?t=1122670), but in the end cause was very simple and yet not obvious.
Side story; the box runs a installation of MySQL that had been mangled when trying to import a database from another box. The MySQL files had been deleted, but I forgot to shutdown the MySQL daemon. So all files used by MySQL was still held by MySQL. This led to disk space being used, but not found when searching for files. the trick to discover the used space was the following:
lsof | grep "deleted"
I know it is a obvious error, but I use a few hours to find this.So heres the tip for you.
Monday, September 9, 2013
Simple copy of file between linux boxes with netcat
I am still pretty new all this Linux sysadmin stuff, so when I get new tricks to to help me I clap my hands and quickly write it down. So here goes.
If you need to copy large amounts between instances, you might not have access to copy between the specified instances via scp. Here netcat, nc, can help you. It opens a direct connection between the two instances, so you can stream bit from one to the other.
On instance B do:
$ tar -cf - . | nc A_ip 4000
On instance A do:
$ nc -l 4000 | tar xvf file1.txt
If you need to send over a lot of files you can use the following on instance A:
$ nc -l 4000 | tar xvf -
If you are sending a a huge amount of data, you might need to throw gzip and gunzip in to the mix:
$ tar -cf - . | gunzip | nc A_ip 4000
$ nc -l 4000 | gzip |tar xvf file1.txt
Of course you need to make sure the ports are open for communication, but most instances have at least one open port that can be used. Just make sure the port is not use by other programs.
Note that netcat syntax differs a bit between the original unix version and the OpenBSD version. The above examples are in the OpenBSD variant.
If you need to copy large amounts between instances, you might not have access to copy between the specified instances via scp. Here netcat, nc, can help you. It opens a direct connection between the two instances, so you can stream bit from one to the other.
Example
I want to send file1.txt from instance A to instance B.On instance B do:
$ tar -cf - . | nc A_ip 4000
On instance A do:
$ nc -l 4000 | tar xvf file1.txt
If you need to send over a lot of files you can use the following on instance A:
$ nc -l 4000 | tar xvf -
If you are sending a a huge amount of data, you might need to throw gzip and gunzip in to the mix:
$ tar -cf - . | gunzip | nc A_ip 4000
$ nc -l 4000 | gzip |tar xvf file1.txt
Of course you need to make sure the ports are open for communication, but most instances have at least one open port that can be used. Just make sure the port is not use by other programs.
Note that netcat syntax differs a bit between the original unix version and the OpenBSD version. The above examples are in the OpenBSD variant.
Reference
- http://www.commandlinefu.com/commands/view/2536/using-netcat-to-copy-files-between-serversFriday, March 15, 2013
Sad day for people who can concentrate for more than 2 minutes
Its a sad day today. Google Reader have been terminated!
In the newest spring cleaning from Google, Google is shutting down Google Reader along side a lot of other stuff. I am not to say wether this is good business or not as seen from Googles point of view. But from my point of view, its a sad day.
I have been using Google Reader for more than 6 years and have grown accustomed to its simplicity, easy navigation and general ease of use. These characteristics are, in my opinion not to be found any where else in any RSS reader, hence a sad day.
The main thesis out in webland is that most people now a days use social media for keeping track of news and therefor there is no use for Google Reader/RSS anymore. That might be right for day to day news, "Elephant ate my baby" kind of stuff, but to me and a lot of others, there a re simply to much stuff I need to keep my eye on and social media is simply going by to fast and to shallow. I need a place where everything is aggregated and stays there until I have decided that it should not any more. Social media today simply does not do this very efficient today. Most social media today is like a flashing bilbard on Time Square, things flashing by to feed people in a hurry and people who cannot concentrate for more that 2 minuts at the time. My guess is that most people disagree with me on that point, but from where I am sitting this is the truth.
Enough ranting on social media for now. The bottom line is that I will be missing my faithful companion Google Reader. Hopefully I will find a new friend that will support me in my daily work and help me stay up to date.
In the newest spring cleaning from Google, Google is shutting down Google Reader along side a lot of other stuff. I am not to say wether this is good business or not as seen from Googles point of view. But from my point of view, its a sad day.
I have been using Google Reader for more than 6 years and have grown accustomed to its simplicity, easy navigation and general ease of use. These characteristics are, in my opinion not to be found any where else in any RSS reader, hence a sad day.
The main thesis out in webland is that most people now a days use social media for keeping track of news and therefor there is no use for Google Reader/RSS anymore. That might be right for day to day news, "Elephant ate my baby" kind of stuff, but to me and a lot of others, there a re simply to much stuff I need to keep my eye on and social media is simply going by to fast and to shallow. I need a place where everything is aggregated and stays there until I have decided that it should not any more. Social media today simply does not do this very efficient today. Most social media today is like a flashing bilbard on Time Square, things flashing by to feed people in a hurry and people who cannot concentrate for more that 2 minuts at the time. My guess is that most people disagree with me on that point, but from where I am sitting this is the truth.
Enough ranting on social media for now. The bottom line is that I will be missing my faithful companion Google Reader. Hopefully I will find a new friend that will support me in my daily work and help me stay up to date.
Wednesday, June 6, 2012
Installing PCNTL for PHP on OSX Lion
Today I needed to install the PCNTL extension for PHP for a tutorial session at the Dutch PHP Conference. And since I am working on OSX Lion, this of course gave some problems due to the rather odd installation of Apache and PHP on OSX.
Several sites on the web gave quick guides for this, but still, as always there are a few things you need to keep in mind for it all to work. I will try to walk through the process as detailed as possible:
First start by installing Xcode. You can get the latest version from the App Store. NOTE that the App Store only have the latest version of Xcode, so if you need a version for Snow Leopard or older, you need to dig deep on the web (https://connect.apple.com is a good place to start).
Next you need to install the Command Line Tools from Xcode. You do this by opening Xcode, go to Preferences (CMD + ,) -> Downloads -> Components and hit install on the Command Line Tools. You can get the Command Line Tools without installing Xcode via https://connect.apple.com
Now you need to find out what version of PHP is installed on OSX
and then get the source code for that version
When the download have finished, you should unpack, find the PCNTL extension, phpize, configure, make and then make install
If phpize is complaining, you are probably missing autoconf. The easiest way to install autoconf is via Homebrew. You install Homebrew by doing
The first thing you need to do afterwards is to run
to find out if any dependencies are missing. Homebrew will telle you what to do, if any is missing.
Lastly you need to enable the PCNTL extension. Do this by adding the following to your php.ini
if you do not know where your php.ini file are, you probably need to create on, by doing
Restart Apache and verify that the PCNTL extension are loaded correctly
If the PCNTL extension for some reason is not loaded, try and copy the pcntl.so from the compiled source code to the extensions directory
Restart apache and verify the the PCNTL extension is loaded.
Resources:
Several sites on the web gave quick guides for this, but still, as always there are a few things you need to keep in mind for it all to work. I will try to walk through the process as detailed as possible:
First start by installing Xcode. You can get the latest version from the App Store. NOTE that the App Store only have the latest version of Xcode, so if you need a version for Snow Leopard or older, you need to dig deep on the web (https://connect.apple.com is a good place to start).
Next you need to install the Command Line Tools from Xcode. You do this by opening Xcode, go to Preferences (CMD + ,) -> Downloads -> Components and hit install on the Command Line Tools. You can get the Command Line Tools without installing Xcode via https://connect.apple.com
Now you need to find out what version of PHP is installed on OSX
$ php -vPHP 5.3.10 with Suhosin-Patch (cli) (built: Feb 20 2012 22:55:53)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologiesand then get the source code for that version
$ curl -O http://us.php.net/distributions/php-5.3.10.tar.gzWhen the download have finished, you should unpack, find the PCNTL extension, phpize, configure, make and then make install
$ tar -xzvf php-5.3.10.tar.gf
$ cd php-5.3.10/ext/pcntl$ phpize$ ./configure$ make$ sudo make installIf phpize is complaining, you are probably missing autoconf. The easiest way to install autoconf is via Homebrew. You install Homebrew by doing
$ /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
The first thing you need to do afterwards is to run
$ brew doctor
to find out if any dependencies are missing. Homebrew will telle you what to do, if any is missing.
Lastly you need to enable the PCNTL extension. Do this by adding the following to your php.ini
extension=pcntl.so
if you do not know where your php.ini file are, you probably need to create on, by doing
sudo cp /private/etc/php.ini.default /private/etc/php.ini
Restart Apache and verify that the PCNTL extension are loaded correctly
$ sudo apachectl restart $ php -m | grep pcntl pcntlIf the PCNTL extension for some reason is not loaded, try and copy the pcntl.so from the compiled source code to the extensions directory
$ sudo cp php-5.3.10/ext/pcntl/modules/pcntl.so /usr/lib/php/extensions/no-debug-non-zts-10090626/
Restart apache and verify the the PCNTL extension is loaded.
Resources:
- http://blog.lancerushing.com/2011/02/getting-phps-pcntl-working-on-snow.html
- http://stackoverflow.com/questions/8430977/phpize-wont-work-on-mac-os-x-lion
- http://mxcl.github.com/homebrew/
- http://stackoverflow.com/questions/9343151/where-is-php-ini-in-mac-os-x-lion-thought-it-was-in-usr-local-php5-lib
- https://github.com/camertron/Pongo/blob/master/INSTALL_PCNTL
Subscribe to:
Posts (Atom)