From owner-freebsd-questions@freebsd.org Tue May 18 21:28:30 2021 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CC463657C62 for ; Tue, 18 May 2021 21:28:30 +0000 (UTC) (envelope-from tomek@cedro.info) Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fl8Hx62Wfz3hpH for ; Tue, 18 May 2021 21:28:29 +0000 (UTC) (envelope-from tomek@cedro.info) Received: by mail-ej1-x630.google.com with SMTP id s22so16595921ejv.12 for ; Tue, 18 May 2021 14:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cedro.info; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vTpdvJ5gOigjMANRigFzPl1mDcOkWD8HVeR0/fsgdbY=; b=QQJ+MPOtd5lbkXN6vVjuq2kl1rmRM97ZpAIyanliXDRAdNLVlZI3675hgeKxm9NaqB V7jK7ZeNnRd91UKccO4qN5rAp7J3JfdGSJzCTAnV0C/bBA1ekDyKQO4MmWty8ueq3xnj iwFZbtJsbm8NBKllB79SxPV4Sh5puibHoDzA0Awxnt3m47wxTZwV7oRkB/ggawXhJaCs jgAhZuqdUk/1fzvf9t2HiZQMghKEl8ruavU3mP8tvncXThf8u4jEjWeeevqyHB+hM9+7 C2870Fg5sQGE6Ca5/lubhq7tzySRIyysCHIvE9iOoSi1lRlDFD/HL0eF6d1TOZ032pe5 n1UQ== 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; bh=vTpdvJ5gOigjMANRigFzPl1mDcOkWD8HVeR0/fsgdbY=; b=ewniiIiZbuvCMFswqqWafS5YO7peBeLvEcHfIsWiauaGxjUjeBHx99fmkI1mf8hUyW CzovPgP4j17dXy8sjKdQu5XQwerwK6R2/J31mFk2cstE/GE8LW4cII4MU8cKHpPCWE5M pFvAo5uOnqCOmH4UrFfTt0bM+mZ6wKsYy6XRJb3NLxBb+ySi9nJq349dPHwn0I23gXMk GutkDFMgTKX5/UIYLJkZVuep3sI0ZOpJ6tI6KAJ4kGatKjMgsrJ5Yj2tD34Cp53cpcDq R/PxQM/L8VSN/dW522mqZg//Xqvxj6tGBKw0gsM4RXlrqBdUgd6SFxGsgIAatgp853+g wIvA== X-Gm-Message-State: AOAM532B3AMPJWumjMyVufdQpxLFbpQ+WojYjUnNYrYgEv5Z47GmjvyY qFIOt44Xx663ZLXUzo9rvVJFOCJPtA4h4hBnEiBddA== X-Google-Smtp-Source: ABdhPJzuL4XW6E3UoCYTVUmbdMKlPOiiJT1CXHAlki30nTm/6t5mNdrhwH9heHTjcIO+H5d6OQpqimNpoZtrYyL4w5k= X-Received: by 2002:a17:906:a245:: with SMTP id bi5mr8456945ejb.316.1621373307897; Tue, 18 May 2021 14:28:27 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Tomasz CEDRO Date: Tue, 18 May 2021 23:28:09 +0200 Message-ID: Subject: Re: Can non-root user create/start services? To: K Lu Cc: FreeBSD Questions Mailing List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4Fl8Hx62Wfz3hpH X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=cedro.info header.s=google header.b=QQJ+MPOt; dmarc=none; spf=none (mx1.freebsd.org: domain of tomek@cedro.info has no SPF policy when checking 2a00:1450:4864:20::630) smtp.mailfrom=tomek@cedro.info X-Spamd-Result: default: False [-2.28 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[cedro.info:s=google]; NEURAL_HAM_MEDIUM(-0.98)[-0.984]; FROM_HAS_DN(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::630:from]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[cedro.info]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::630:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[cedro.info:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::630:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; R_SPF_NA(0.00)[no SPF record]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2021 21:28:30 -0000 On Tue, May 18, 2021 at 10:52 PM K Lu wrote: > Right, I don't want to change to root for those tasks. > > That's why I'm curious, if the user can define and start "per-user" > services. Not sure if I elaborate the use cases well :) > > Another option I can think of is using user cron jobs. Are there other options? Cron is good to run periodic tasks - every hour, day, week, month. You may want to put your local services into ~/.profile but that requires login for them to be launched. They would not launch at boot. You may set a system service to run as selected local user (i.e. vbox) so you can access and probably control them as selected user (i.e. manually kill, kill -HUP, start beyond system service). You may put some services or script into /etc/rc.d/local that would launch your local user services. You may provide a web interface to see status and provide enable/disable switch if you do not even want to login. Either way you would probably have to create a control (start/stop/status) scripts for your local services in your home directory (i.e. $HOME/.local/etc/rc.d/). They could be started with /etc/rc.d/local at boot or periodically controlled by cron - when not running start would take place, when running no action taken, when crashed they would start again. Cron will however execute them no matter if you like it or not, so either you edit your cron (crontab -e) or some additional enable/disable flag for a service would have to be part of your local configuration scripts. You may take a look at /etc/rc.d/local as an example :-) Good luck! :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info