少なくともDebianベースのシステムにはrun-parts
ユーティリティがありますツールさまざまなスクリプトで使用されるパッケージです。たとえば、/etc/X11/Xsessionはディレクトリ内のすべての実行可能ファイルを実行します。オプションまたはユーティリティfind
で使用できますが、実行中のコンポーネントが必要なのはなぜですか?また、実行可能ファイルと見なされるものは何ですか?ファイル権限だけを確認するのではないようです。-perm
test
run-parts
# run-parts --list --lsbsysinit /etc/X11/Xsession.d | tail -1
/etc/X11/Xsession.d/90x11-common_ssh-agent
# ls -l /etc/X11/Xsession.d/90x11-common_ssh-agent
-rw-r--r-- 1 root root 629 2010-11-02 23:17 /etc/X11/Xsession.d/90x11-common_ssh-agent
# head /etc/X11/Xsession.d/90x11-common_ssh-agent
# $Id: 90x11-common_ssh-agent 305 2005-07-03 18:51:43Z dnusinow $
# This file is sourced by Xsession(5), not executed.
STARTSSH=
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS=
if has_option use-ssh-agent; then
if [ -x "$SSHAGENT" ] && [ -z "$SSH_AUTH_SOCK" ] \
#
ベストアンサー1
find
代わりに使用できますrun-parts
。どちらが良いかを知る方法はありません。しかし、私の考えでは、run-parts
より短く(より少ないタイピング)使用してスクリプトをより保守しやすくするようです。例は次のとおりです/etc/crontab
。
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
debianutils
2番目の質問の場合は、ソースコードで答えを見つけることができます。ファイルのrun-parts.c
198行目:
/* Execute a file */
void run_part(char *progname)
{
....
args[0] = progname;
execv(progname, args);
error("failed to exec %s: %s", progname, strerror(errno));
exit(1);
....
}
システムコールをrun-parts
使用して表示できます。execv
したがって、ファイルがバイナリ実行可能ファイルではないかInterpreter script
。execv
ノート
- 何ですか
Interpreter script
:
man execve
、部分からInterpreter scripts
:
Interpreter scripts
An interpreter script is a text file that has execute permission
enabled and whose first line is of the form:
#! interpreter [optional-arg]
The interpreter must be a valid pathname for an executable which is not
itself a script. If the filename argument of execve() specifies an
interpreter script, then interpreter will be invoked with the following
arguments:
interpreter [optional-arg] filename arg...
where arg... is the series of words pointed to by the argv argument of
execve().
For portable use, optional-arg should either be absent, or be specified
as a single word (i.e., it should not contain white space); see NOTES
below.
- debianutilsのソースコードを見ることができますここ。