Bash tricks » History » Version 4
Alexis Jeandet, 30/03/2014 03:47 PM
1 | 3 | Alexis Jeandet | {{>toc}} |
---|---|---|---|
2 | |||
3 | 1 | Alexis Jeandet | h1. Bash tricks |
4 | |||
5 | 3 | Alexis Jeandet | h2. Get disk usage |
6 | 1 | Alexis Jeandet | |
7 | <pre><code class="bash"> |
||
8 | df -h |
||
9 | </code></pre> |
||
10 | |||
11 | Will give you something like this: |
||
12 | |||
13 | <pre> |
||
14 | Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur |
||
15 | /dev/sde1 110G 8,1G 97G 8% / |
||
16 | devtmpfs 126G 0 126G 0% /dev |
||
17 | tmpfs 126G 0 126G 0% /dev/shm |
||
18 | tmpfs 126G 920K 126G 1% /run |
||
19 | tmpfs 126G 0 126G 0% /sys/fs/cgroup |
||
20 | tmpfs 126G 4,0K 126G 1% /tmp |
||
21 | /dev/mapper/ddf1_DATA2 15T 7,7G 14T 1% /home |
||
22 | </pre> |
||
23 | |||
24 | 3 | Alexis Jeandet | h2. Get CPU and RAM usage |
25 | 1 | Alexis Jeandet | |
26 | <pre><code class="bash"> |
||
27 | htop |
||
28 | </code></pre> |
||
29 | |||
30 | Will give you something like this: |
||
31 | |||
32 | p=. !{width: 80%}htop.png(htop screenshot example)! |
||
33 | 2 | Alexis Jeandet | |
34 | To get more information about htop see "here":http://htop.sourceforge.net/index.php?page=main |
||
35 | 4 | Alexis Jeandet | |
36 | |||
37 | h2. Start a Job without a queue |
||
38 | |||
39 | All process started from ssh are terminated when you close the ssh connection, even if you fork them |
||
40 | (./app &). They are closed because when a process is closed the system send the SIGTERM signal |
||
41 | to all its children, it’s done to avoid zombies process on a machine. To keep your task alive when |
||
42 | you disconnect from ssh, you should use screen ("tutorial":http://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/), it will block the SIGTERM signal. To |
||
43 | start your application with screen: |
||
44 | |||
45 | <pre><code class="bash"> |
||
46 | screen # to start screen |
||
47 | ./your_app #to start your application or any other command |
||
48 | #type ’ Ctrl −A’ d to leave screen with your application running in background |
||
49 | </code></pre> |
||
50 | |||
51 | To reconnect to your previous session: |
||
52 | |||
53 | <pre><code class="bash"> |
||
54 | screen −ls # to list running sessions |
||
55 | screen −r 33287.pts−36.bender # to reconnect to 33287.pts−36.bender session |
||
56 | exit # to close your screen session |
||
57 | </code></pre> |