Bash tricks » History » Version 6
Alexis Jeandet, 30/03/2014 03:48 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 | h2. Start a Job without a queue |
||
37 | |||
38 | All process started from ssh are terminated when you close the ssh connection, even if you fork them |
||
39 | (./app &). They are closed because when a process is closed the system send the SIGTERM signal |
||
40 | to all its children, it’s done to avoid zombies process on a machine. To keep your task alive when |
||
41 | 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 |
||
42 | start your application with screen: |
||
43 | |||
44 | <pre><code class="bash"> |
||
45 | screen # to start screen |
||
46 | 1 | Alexis Jeandet | ./your_app #to start your application or any other command |
47 | 5 | Alexis Jeandet | #type ’ Ctrl-A’ d to leave screen with your application running in background |
48 | 4 | Alexis Jeandet | </code></pre> |
49 | |||
50 | To reconnect to your previous session: |
||
51 | 1 | Alexis Jeandet | |
52 | <pre><code class="bash"> |
||
53 | 6 | Alexis Jeandet | screen -ls # to list running sessions |
54 | 5 | Alexis Jeandet | screen -r 33287.pts-36.bender # to reconnect to 33287.pts-36.bender session |
55 | 4 | Alexis Jeandet | exit # to close your screen session |
56 | 5 | Alexis Jeandet | </code></pre> |