Project

General

Profile

Bash tricks » History » Version 11

Alexis Jeandet, 30/03/2014 03:58 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>
57 7 Alexis Jeandet
58
h2. Start a mpi code:
59 1 Alexis Jeandet
60 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.
61 7 Alexis Jeandet
62 1 Alexis Jeandet
<pre><code class="bash">
63
mpirun -np 32 /path_to_myapp/myapp
64 8 Alexis Jeandet
#to run myapp with 32 MPI processes 
65
</code></pre>
66
67
h2. Start a openMP code:
68
69
When you run a software compiled with openMP library, you can tune the number of openMP threads your
70
code will run. To do this you just have to set the OMP_NUM_THREADS environment variable.
71
72
<pre><code class="bash">
73
export OMP_NUM_THREADS=32
74
/path_to_myapp/myapp
75
#to run myapp with 32 openMP threads
76 7 Alexis Jeandet
</code></pre>