From ba7f29a6c38176f7d9466a5a1ff104ceb564be9e Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Fri, 24 Oct 2003 17:48:36 +0000 Subject: [PATCH] Added new --quiet option to scancel so jobs that are already done don't report an error message. --- doc/man/man1/scancel.1 | 9 +++++++-- src/scancel/opt.c | 19 ++++++++++++------- src/scancel/scancel.c | 14 +++++++++----- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/doc/man/man1/scancel.1 b/doc/man/man1/scancel.1 index b76a2691064..3e997266fcd 100644 --- a/doc/man/man1/scancel.1 +++ b/doc/man/man1/scancel.1 @@ -1,4 +1,4 @@ -.TH SCANCEL "1" "October 2003" "scancel 0.2" "Slurm components" +.TH SCANCEL "1" "October 2003" "scancel 0.3" "Slurm components" .SH "NAME" scancel \- Used to signal jobs or job steps that are under the control of Slurm. .SH "SYNOPSIS" @@ -28,6 +28,10 @@ The name of jobs to be signaled. \fB\-p\fR, \fB\-\-partition\fR=\fIpartition_name\fR The name of the partition from which jobs are to be signaled. .TP +\fB\-q\fR, \fB\-\-quiet\fR +Do not report an error if the specified job is already completed. +This option is incompatible with the \fB\-\-verbose\fR option. +.TP \fB\-s\fR, \fB\-\-signal\fR=\fIsignal_name\fR The name or number of the signal to be send. Default value is "KILL". .TP @@ -39,7 +43,8 @@ either "PENDING" or "RUNNING". The name of the user whose jobs are to be signaled. .TP \fB\-v\fR, \fB\-\-verbose\fR -Print additional logging. Multiple v's increase logging detail. +Print additional logging. Multiple v's increase logging detail. +This option is incompatible with the \fB\-\-quiet\fR option. .TP \fB\-V\fR, \fB\-\-Version\fR Print the version number of the scontrol command. diff --git a/src/scancel/opt.c b/src/scancel/opt.c index 1c24764cc67..ee051010b27 100644 --- a/src/scancel/opt.c +++ b/src/scancel/opt.c @@ -204,7 +204,7 @@ static void _opt_default() opt.state = JOB_END; opt.user_name = NULL; opt.user_id = 0; - opt.verbose = false; + opt.verbose = 0; } /* @@ -250,13 +250,13 @@ static void _opt_env() if ( (val=getenv("SCANCEL_VERBOSE")) ) { if (strcasecmp(val, "true") == 0) - opt.verbose = true; + opt.verbose = 1; else if (strcasecmp(val, "T") == 0) - opt.verbose = true; + opt.verbose = 1; else if (strcasecmp(val, "false") == 0) - opt.verbose = false; + opt.verbose = 0; else if (strcasecmp(val, "F") == 0) - opt.verbose = false; + opt.verbose = 0; else error ("Unrecognized SCANCEL_VERBOSE value: %s", val); @@ -274,6 +274,7 @@ static void _opt_args(int argc, char **argv) {"interactive", no_argument, 0, 'i'}, {"name", required_argument, 0, 'n'}, {"partition", required_argument, 0, 'p'}, + {"quiet", no_argument, 0, 'q'}, {"signal", required_argument, 0, 's'}, {"state", required_argument, 0, 't'}, {"user", required_argument, 0, 'u'}, @@ -283,7 +284,7 @@ static void _opt_args(int argc, char **argv) {"usage", no_argument, 0, OPT_LONG_USAGE} }; - while((opt_char = getopt_long(argc, argv, "in:p:s:t:u:vV", + while((opt_char = getopt_long(argc, argv, "in:p:qs:t:u:vV", long_options, &option_index)) != -1) { switch (opt_char) { case (int)'?': @@ -299,6 +300,9 @@ static void _opt_args(int argc, char **argv) case (int)'p': opt.partition = xstrdup(optarg); break; + case (int)'q': + opt.verbose = -1; + break; case (int)'s': opt.signal = _xlate_signal_name(optarg); break; @@ -429,7 +433,7 @@ static void _opt_list(void) static void _usage(void) { - printf("Usage: scancel [-n job_name] [-u user] [-p partition] [-s name | integer]\n"); + printf("Usage: scancel [-n job_name] [-u user] [-p partition] [-q] [-s name | integer]\n"); printf(" [-t PENDING | RUNNING] [--usage] [-v] [-V] [job_id[.step_id]]\n"); } @@ -439,6 +443,7 @@ static void _help(void) printf(" -i, --interactive require response from user for each job\n"); printf(" -n, --name=job_name name of job to be signalled\n"); printf(" -p, --partition=partition name of job's partition\n"); + printf(" -q, --quiet disable warnings\n"); printf(" -s, --signal=name | integer signal to send to job, default is SIGKILL\n"); printf(" -t, --states=states states to jobs to cancel,\n"); printf(" default is pending and running,\n"); diff --git a/src/scancel/scancel.c b/src/scancel/scancel.c index c765ab7a57b..d7f3030d009 100644 --- a/src/scancel/scancel.c +++ b/src/scancel/scancel.c @@ -72,7 +72,7 @@ main (int argc, char *argv[]) if (opt.verbose) { log_opts.stderr_level += opt.verbose; log_alter (log_opts, SYSLOG_FACILITY_DAEMON, NULL); - } + } if ((opt.interactive) || (opt.job_name) || @@ -229,8 +229,10 @@ _cancel_job_id (uint32_t job_id, uint16_t signal) sleep ( 5 + i ); } if (error_code) { - error("Kill job error on job id %u: %s", - job_id, slurm_strerror(slurm_get_errno())); + error_code = slurm_get_errno(); + if ((opt.verbose >= 0) || (error_code != ESLURM_ALREADY_DONE )) + error("Kill job error on job id %u: %s", + job_id, slurm_strerror(slurm_get_errno())); } } @@ -249,8 +251,10 @@ _cancel_step_id (uint32_t job_id, uint32_t step_id, uint16_t signal) sleep ( 5 + i ); } if (error_code) { - error("Kill job error on job id %u.%u: %s", - job_id, step_id, slurm_strerror(slurm_get_errno())); + error_code = slurm_get_errno(); + if ((opt.verbose >= 0) || (error_code != ESLURM_ALREADY_DONE )) + error("Kill job error on job id %u.%u: %s", + job_id, step_id, slurm_strerror(slurm_get_errno())); } } -- GitLab