From owner-freebsd-stable@freebsd.org Wed Apr 10 21:40:49 2019 Return-Path: Delivered-To: freebsd-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 908F6156E1D5 for ; Wed, 10 Apr 2019 21:40:49 +0000 (UTC) (envelope-from wfc@mintsol.com) Received: from scully.mintsol.com (scully.mintsol.com [199.182.77.206]) by mx1.freebsd.org (Postfix) with ESMTP id 95EB78CA83 for ; Wed, 10 Apr 2019 21:40:48 +0000 (UTC) (envelope-from wfc@mintsol.com) Received: from mintsol.com (officecc.mintsol.com [96.85.114.33]) by scully.mintsol.com with esmtp; Wed, 10 Apr 2019 17:40:41 -0400 id 00ACDC00.000000005CAE62DA.0000F3D6 Received: from localhost (localhost [127.0.0.1]) (IDENT: uid 1002) by mintsol.com with esmtp; Wed, 10 Apr 2019 17:40:42 -0400 id 0000080E.5CAE62DA.00004781 Date: Wed, 10 Apr 2019 17:40:42 -0400 (EDT) From: Walter Cramer To: Software Info cc: Jonathan Chen , "freebsd-stable@freebsd.org" Subject: RE: Crontab Question In-Reply-To: <5cae5cc3.1c69fb81.15e0.dbd1@mx.google.com> Message-ID: <20190410172638.C14867@mulder.mintsol.com> References: <5cae4e6f.1c69fb81.95785.62bf@mx.google.com> <5cae5cc3.1c69fb81.15e0.dbd1@mx.google.com> MIME-Version: 1.0 Content-ID: <20190410173428.C14867@mulder.mintsol.com> X-Rspamd-Queue-Id: 95EB78CA83 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of wfc@mintsol.com designates 199.182.77.206 as permitted sender) smtp.mailfrom=wfc@mintsol.com X-Spamd-Result: default: False [-1.43 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; NEURAL_HAM_MEDIUM(-0.94)[-0.939,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+a:scully.mintsol.com]; NEURAL_HAM_LONG(-0.96)[-0.963,0]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; DMARC_NA(0.00)[mintsol.com]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[bmx01.pofox.com]; CTYPE_MIXED_BOGUS(1.00)[]; NEURAL_HAM_SHORT(-0.30)[-0.303,0]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+]; ASN(0.00)[asn:22768, ipnet:199.182.77.0/24, country:US]; IP_SCORE(-0.01)[country: US(-0.06)] Content-Type: TEXT/PLAIN; CHARSET=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Apr 2019 21:40:49 -0000 On Wed, 10 Apr 2019, Software Info wrote: > OK. So although the script is located in my home directory, it doesn=E2= =80=99t=20 > start there? Sorry but I don=E2=80=99t quite understand. Could you expla= in a=20 > little further please? Both 'cp' and 'ls' are located in /bin. But if I run the 'ls' command in= =20 /root, 'ls' can't find 'cp' (unless I tell it where to look) - even though= =20 /bin *is* in my PATH - server7:/root # ls cp ls: cp: No such file or directory server7:/root # ls /bin/cp /bin/cp Where the system looks for *commands*, to execute, is different from where= =20 it looks for other files, which those commands use. The latter is=20 generally only the current directory (unless you tell it otherwise).=20 When cron runs a script as root, "current directory" will be /root. BUT - for security and other reasons, it would be better to have cron run= =20 your script as you (not root), and as '/home/me/myscript' (instead of=20 adding your home directory to PATH in /etc/crontab). -Walter From owner-freebsd-stable@freebsd.org Wed Apr 10 21:43:37 2019 Return-Path: Delivered-To: freebsd-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59767156E564 for ; Wed, 10 Apr 2019 21:43:37 +0000 (UTC) (envelope-from jonc@chen.org.nz) Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6DE9A8CF85 for ; Wed, 10 Apr 2019 21:43:36 +0000 (UTC) (envelope-from jonc@chen.org.nz) Received: by mail-vs1-xe2b.google.com with SMTP id g187so2265307vsc.8 for ; Wed, 10 Apr 2019 14:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chen-org-nz.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=st5EF6Toj4oaftpjqMp60Jwg7uVMLOwxgM2q05BzpoY=; b=BHbrJEJoZ2erusel0A94uhdfWRf+4Ud4FvxI0vJd3v3sYHo1hxG8k8L/5MnirVY9b0 WQV5xZvXUVpbGsNQp82sIhh9Wa0budkXfF5RIVKMbXQSxeIvBKYZ3kLvWFIUOUOkfqb1 h3tY+plgS6zseUnJCZ8eLTONmv8tA5vnYfCoY8lSogzRQ4wTMYXV4OHlqwdqtUldGHnt /ZujFsP+2OIjUTVdXtBa2CQacSd3URCEmqnSTUd/LVfyWAFIGpFNO8SvDLBFh/m7vtmA F9dbTzmdcvUJFRw1WJW8JRSIkU7TuiDcpwL3WB08MELkoAFBhALVASZoEKPQEOqQLGhT IKKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=st5EF6Toj4oaftpjqMp60Jwg7uVMLOwxgM2q05BzpoY=; b=EYv/2kJhGjT5+bMo3bnlDfyDk/uYJezO5FnoRv76zN6kFbHi01NeDPLnni23ma02Lu +KmkyNWupKerCth8HsBd52jieJH452TsopF536+qm8p/Q0QnzHHPxkQMMWSuDwixGiWu WfEdS0g9/yZsXnGudaJT0+v+X5HUVdn5pMz7cs8S5JDLQtyWLPMXiHQ6x/Gx02PkeF+I oZfq0ohW9EvurH5I3VG6Dfo4wQxomdQwQ2sHMsvmG0X3erHTlcZoL1gSqGfl21sKFCMp k5aJ7kTQJ+lt8NjRz8Vp/PMmQ1hj0/EGOVpVyz6P+Ov0Z5Urfbq0Up0J41BUE5aKCWmn 8+eA== X-Gm-Message-State: APjAAAUFA7vgcv9DYy9CzZIYObCgSMoPO2KMW6eOecylj5Zc/UA7v2Jl GFDCnomMApxhbj4xxst/cd9+TQaFwagJjUUP5v3mEw== X-Google-Smtp-Source: APXvYqwTYBfq8nIPn/8p3EZvyUA+PSOidDp4kKxr+5TcVNRlp0C31mrjo3ztD8+lFb3cQeZptGp3Obd3l2Sjl1NKdcY= X-Received: by 2002:a67:844d:: with SMTP id g74mr26014840vsd.40.1554932615491; Wed, 10 Apr 2019 14:43:35 -0700 (PDT) MIME-Version: 1.0 References: <5cae4e6f.1c69fb81.95785.62bf@mx.google.com> <5cae5cc3.1c69fb81.15e0.dbd1@mx.google.com> <5cae6179.1c69fb81.12661.3a08@mx.google.com> In-Reply-To: <5cae6179.1c69fb81.12661.3a08@mx.google.com> From: Jonathan Chen Date: Thu, 11 Apr 2019 09:43:19 +1200 Message-ID: Subject: Re: Crontab Question To: Software Info Cc: "freebsd-stable@freebsd.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 6DE9A8CF85 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=chen-org-nz.20150623.gappssmtp.com header.s=20150623 header.b=BHbrJEJo X-Spamd-Result: default: False [-6.20 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; R_DKIM_ALLOW(-0.20)[chen-org-nz.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.91)[-0.913,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-stable@freebsd.org]; DMARC_NA(0.00)[chen.org.nz]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[chen-org-nz.20150623.gappssmtp.com:+]; MX_GOOD(-0.01)[cached: alt1.aspmx.l.google.com]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[b.2.e.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(-2.98)[ip: (-9.68), ipnet: 2607:f8b0::/32(-2.96), asn: 15169(-2.19), country: US(-0.06)] X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Apr 2019 21:43:37 -0000 On Thu, 11 Apr 2019 at 09:34, Software Info wro= te: > > I see. I had however copied the output of env to the etc/crontab PATH lin= e. Wouldn=E2=80=99t that care for an environment issue though? When I say "environment", I mean it in the generic sense; including working-directory. However, best practise is to keep /etc/crontab as minimal as possible, and to set up environ(7) within the invoked script-file. Security-wise, you should just keep PATH in /etc/crontab to the standard, and invoke your script with: * * * * * user /path/to/my/script This is especially important when running as root. Cheers. --=20 Jonathan Chen