Navigation

    ML
    • Register
    • Login
    • Search
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

    LVM Snapshot script

    IT Discussion
    bash lvm snapshots
    2
    3
    964
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stacksofplates
      stacksofplates last edited by

      So I noticed an issue, I figured I'd post it in case anyone else has the same problem.

      I created a bash script on a CentOS 7 server to do some LVM snapshots and then export them to .gzip files. If I put the script under /etc/cron.daily it worked fine, however if I added the script in crontab as root or sudo, the script would run, but would give the error command not found for lvcreate and lvremove.

      I just had to add this to the script:

      PATH=/usr/sbin:/usr/bin:/sbin:/bin
      

      and it works fine now.

      1 Reply Last reply Reply Quote 1
      • scottalanmiller
        scottalanmiller last edited by

        Best practice, which almost no one follows, is to use explicit paths in scripts rather than implicit. then you don't need that at all.

        stacksofplates 1 Reply Last reply Reply Quote 1
        • stacksofplates
          stacksofplates @scottalanmiller last edited by

          @scottalanmiller said:

          Best practice, which almost no one follows, is to use explicit paths in scripts rather than implicit. then you don't need that at all.

          I guess that makes 100% sense since you have to start the script with an absolute path ha.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post