diff --git a/bin/cylc-cat-log b/bin/cylc-cat-log index 287f5936207..7e53add0f9d 100755 --- a/bin/cylc-cat-log +++ b/bin/cylc-cat-log @@ -18,9 +18,9 @@ """cylc [info] cat-log|log [OPTIONS] ARGS -Print, edit, or tail-follow content, or print path or list directory, of local -or remote task job logs and suite server logs. Batch-system-specific job cat or -tail commands are used if defined in global config. +Cat (print), edit, or tail-follow content, or print path or list directory, of +local or remote task job logs and suite server logs. Batch-system view commands +(e.g. 'qcat') are used if defined in global config and the job is running. For standard log types use the short-cut option argument or full filename (e.g. for job stdout "-f o" or "-f job.out" will do). @@ -28,9 +28,13 @@ for job stdout "-f o" or "-f job.out" will do). To list the local job log directory of a remote task, choose "-m l" (directory list mode) and a local file, e.g. "-f a" (job-activity.log). -Custom job logs are assumed to reside on the job host. These will be available -to view from the GUI if listed in 'extra log files' in the suite definition. -Here the file name must be given (but it can be discovered with list-dir mode). +If remote job logs are retrieved to the suite host on completion (global config +'[JOB-HOST]retrieve job logs = True') and the job is not currently running, the +local (retrieved) log will be accessed unless '-o/--force-remote' is used. + +Custom job logs (written to $CYLC_TASK_LOG_ROOT on the job host) are available +from the GUI if listed in 'extra log files' in the suite definition. The file +name must be given here, but can be discovered with '--mode=l' (list-dir). The correct cycle point format of the suite must be for task job logs. @@ -195,6 +199,12 @@ def get_option_parser(): "next oldest, etc.", metavar="INT", action="store", dest="rotation_num") + parser.add_option( + "-o", "--force-remote", + help="View remote logs remotely even if they have been retrieved" + " to the suite host (default False).", + action="store_true", default=False, dest="force_remote") + parser.add_option( "-s", "--submit-number", "-t", "--try-number", help="Job submit number (default=%s, i.e. latest)." % NN, @@ -351,8 +361,8 @@ def main(): user, host = split_user_at_host(user_at_host) batchview_cmd = None if live_job_id is not None: - # Get special batch system log viewer command (e.g. qcat) if one - # exists, the log is out or err, and the job is live. + # Job is currently running. Get special batch system log view + # command (e.g. qcat) if one exists, and the log is out or err. conf_key = None if options.filename == JOB_LOG_OUT: if options.mode == 'c': @@ -374,8 +384,12 @@ def main(): if batchview_cmd_tmpl is not None: batchview_cmd = batchview_cmd_tmpl % { "job_id": str(live_job_id)} - pout = None - if is_remote(user, host) and (options.filename not in JOB_LOGS_LOCAL): + + log_is_remote = (is_remote(user, host) + and (options.filename not in JOB_LOGS_LOCAL)) + log_is_retrieved = (glbl_cfg().get_host_item('retrieve job logs', host) + and live_job_id is None) + if log_is_remote and (not log_is_retrieved or options.force_remote): logpath = os.path.normpath(os.path.join( glbl_cfg().get_derived_host_item( suite_name, "suite job log directory", host, user),