0

I have some shell scripts that I have symlinked into /etc/cron.daily.

When I run the script as root it completes without any errors and do what needs to get done. I even added

source $HOME/.bash_profile

to the scripts but to no avail. The scripts use git and curl to update packages daily.

When I try run-parts /etc/cron.daily/ it never completes.

Files inside /etc/cron.daily:

 check_updates -> /opt/devops/automation/server/utilities/check_updates.sh
 etckeeper
 install-external_utilities -> /opt/devops/automation/server/utilities/install-external_utilities.sh
 logrotate
 lynis_updates
3
  • 1
    Is there any chance of getting to see the script? Is the git or curl commands using any form of authentication that requires e.g. the SSH agent or interaction with a user?
    – Kusalananda
    Commented Nov 12, 2021 at 10:45
  • 1
    Make sure to provide absolute paths to programs you are running in the script (/usr/bin/curl instead of curl)
    – Panki
    Commented Nov 12, 2021 at 10:47
  • @Panki It would be a bit odd if /usr/bin was not part of $PATH already, and I probably opt for adding it (and any other needed directory) to the end of $PATH in the script rather than using absolute paths everywhere.
    – Kusalananda
    Commented Nov 12, 2021 at 11:04

1 Answer 1

1

I added the below to both scripts, I realised only the one had the entry in it. After that the 2 scripts completed with testing by run-parts.

# Import Env
source $HOME/.bash_profile

Update

Even the fix above did not work reliably. I tried various recommendations and eventually settled to update my shebang.

#!/bin/bash -l

Just don't use that for a script that will load as part of a user's login.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .