0

i am trying to setup a script to be run as systemd service running as a different user than root. My .service looks like this:

schedulescript.service

[Unit]

Description=Scheduler Script service

Requires = rsyslog.service network.target

After = rsyslog.service network.target

[Service]

Type=simple

User=svc.schd

ExecStart=/bin/sh /u01/apps/schedulescript.sh

[Install]

WantedBy=multi-user.target


When run as "systemctl start schedulescript.service" it works fine however upon reboot it fails with below status


**Aug 17 13:11:07 dfw-vd-gwalt3.dev.svbank.com systemd[1]: Started Schedulescript Script service.

Aug 17 13:11:07 dfw-vd-gwalt3.dev.svbank.com systemd[1]: schedulescript.service: main process exited, code=exited, status=217/USER

Aug 17 13:11:07 dfw-vd-gwalt3.dev.svbank.com systemd[1]: Unit schedulescript.service entered failed state.

Aug 17 13:11:07 dfw-vd-gwalt3.dev.svbank.com systemd[1]: schedulescript.service failed.


I believe this is happening because upon reboot when it tries to execute it cannot find svc.schd user as it has not come up properly.

When i get a proper response for "systemd-analyze" and then try to run the service it works fine.

If anyone can tell what is the service which has to be set in "After" block so that my service can wait on that specific user to be available after reboot?

2
  • How exactly are users "loaded" on your system in the first place? (Are you using LDAP? NIS? Active Directory?)
    – user1686
    Aug 17, 2020 at 16:09
  • its AD based. the problem statement i have posted is from my Org and the user management is done by a different team (Linux support group) hence had to change a couple of details in the query. i was wondering if there is anyway to push to run post full boot is completed, haven't found it yet though. Aug 17, 2020 at 16:32

1 Answer 1

0

Fixed. The dependency has to be set for vasd.service which works with AD. Added it After block and my service works properly on reboot now.

After = rsyslog.service network.target vasd.service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.