help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Profile bash script


From: Eduardo Bustamante
Subject: Re: [Help-bash] Profile bash script
Date: Sat, 1 Dec 2018 08:55:05 -0800

On Sat, Dec 1, 2018 at 4:09 AM Peng Yu <address@hidden> wrote:
>
> Hi,
>
> I’d like to check how frequent each external command is called by a bunch
> of bash scripts (one may call another).

You can use strace:

address@hidden:~$ strace -fe execve -tt bash -c 'date; echo hi; hostname'
08:54:31.502301 execve("/bin/bash", ["bash", "-c", "date; echo hi;
hostname"], 0x7ffcafcf1c48 /* 33 vars */) = 0
strace: Process 2413 attached
[pid  2413] 08:54:31.515721 execve("/bin/date", ["date"],
0x556ac5071280 /* 33 vars */) = 0
Sat Dec  1 08:54:31 PST 2018
[pid  2413] 08:54:31.523498 +++ exited with 0 +++
08:54:31.523768 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED,
si_pid=2413, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
hi
strace: Process 2414 attached
[pid  2414] 08:54:31.527918 execve("/bin/hostname", ["hostname"],
0x556ac5081f40 /* 33 vars */) = 0
debian
[pid  2414] 08:54:31.531035 +++ exited with 0 +++
08:54:31.531259 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED,
si_pid=2414, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
08:54:31.531900 +++ exited with 0 +++



reply via email to

[Prev in Thread] Current Thread [Next in Thread]