Bash tricks » History » Version 14
Alexis Jeandet, 01/04/2014 06:30 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 | 12 | Alexis Jeandet | All process started from ssh are terminated when you close the ssh connection, even if you fork them (./app &). They are closed because when a process is closed the system send the SIGTERM signal to all its children, it’s done to avoid zombies process on a machine. To keep your task alive when 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 start your application with screen: |
39 | 4 | Alexis Jeandet | |
40 | <pre><code class="bash"> |
||
41 | screen # to start screen |
||
42 | 1 | Alexis Jeandet | ./your_app #to start your application or any other command |
43 | 5 | Alexis Jeandet | #type ’ Ctrl-A’ d to leave screen with your application running in background |
44 | 4 | Alexis Jeandet | </code></pre> |
45 | |||
46 | To reconnect to your previous session: |
||
47 | 1 | Alexis Jeandet | |
48 | <pre><code class="bash"> |
||
49 | 6 | Alexis Jeandet | screen -ls # to list running sessions |
50 | 5 | Alexis Jeandet | screen -r 33287.pts-36.bender # to reconnect to 33287.pts-36.bender session |
51 | 4 | Alexis Jeandet | exit # to close your screen session |
52 | 5 | Alexis Jeandet | </code></pre> |
53 | 7 | Alexis Jeandet | |
54 | h2. Start a mpi code: |
||
55 | 1 | Alexis Jeandet | |
56 | 11 | Alexis Jeandet | Please note that the default mpi distribution on "Bender":https://hephaistos.lpp.polytechnique.fr/redmine/projects/hpc/wiki/Computers#Bender /"Flexo":https://hephaistos.lpp.polytechnique.fr/redmine/projects/hpc/wiki/Computers#Flexo /"Jakolass":https://hephaistos.lpp.polytechnique.fr/redmine/projects/hpc/wiki/Computers#Jakolass is a custom one compiled with intel compiler and libraries, to use the gcc one you should call mpi(cc/f90/run/...) with the full path /usr/lib64/openmpi/bin/mpi(cc/f90/run/...). To run a software compiled with mpi (mpic/cxx/fortran), uses mpirun with -np to set the number of mpi processes you want to start. |
57 | 7 | Alexis Jeandet | |
58 | 1 | Alexis Jeandet | <pre><code class="bash"> |
59 | mpirun -np 32 /path_to_myapp/myapp |
||
60 | #to run myapp with 32 MPI processes |
||
61 | 8 | Alexis Jeandet | </code></pre> |
62 | |||
63 | h2. Start a openMP code: |
||
64 | |||
65 | 12 | Alexis Jeandet | When you run a software compiled with openMP library, you can tune the number of openMP threads your code will run. To do this you just have to set the OMP_NUM_THREADS environment variable. |
66 | 8 | Alexis Jeandet | |
67 | <pre><code class="bash"> |
||
68 | export OMP_NUM_THREADS=32 |
||
69 | /path_to_myapp/myapp |
||
70 | #to run myapp with 32 openMP threads |
||
71 | 7 | Alexis Jeandet | </code></pre> |
72 | 13 | Alexis Jeandet | |
73 | h2. Abort a Job: |
||
74 | |||
75 | To stop a running job you can use the kill command in different ways |
||
76 | * You have just on Job running on the machine and you know its name |
||
77 | |||
78 | <pre><code class="bash"> |
||
79 | killall TheNameOfTheJob |
||
80 | </code></pre> |
||
81 | |||
82 | * You have multiple jobs running, you have first to get the Process ID of the job |
||
83 | |||
84 | <pre><code class="bash"> |
||
85 | ps ax # will list the running processes |
||
86 | # You can filter, for example if you have started your job with mpi |
||
87 | 14 | Alexis Jeandet | ps ax | grep mpi |
88 | </code></pre> |
||
89 | 13 | Alexis Jeandet | |
90 | 14 | Alexis Jeandet | The first number you get is the Process ID |
91 | |||
92 | To kill it |
||
93 | |||
94 | <pre><code class="bash"> |
||
95 | kill -9 123456 # if 123456 is your Process ID |
||
96 | 13 | Alexis Jeandet | </code></pre> |