bash script does not run when trying to exec into a container
Linux - ContainersThis forum is for the discussion of all topics relating to Linux containers. Docker, LXC, LXD, runC, containerd, CoreOS, Kubernetes, Mesos, rkt, and all other Linux container platforms are welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Defaulting container name to mongo.
tar: Removing leading `/' from member names
Backup finished on 09-21-18/22:52:20 and took 4 seconds to finish
Backup ./mongobackups/092118 copied to node5
mkdir: cannot create directory ‘./mongobackups/092118’: No such file or directory
/home/admin/MONGODB-BACKUP/mongodump.sh: line 6: kubectl: command not found
/home/admin/MONGODB-BACKUP/mongodump.sh: line 8: kubectl: command not found
Backup finished on 09-21-18/23:50:04 and took 3 seconds to finish
./mongobackups/092118: No such file or directory
Backup ./mongobackups/092118 copied to node5
i have it run under cron and it fails . if i manually execute it like so ./mongodumb.sh >> datelog 2>&1 it works fine
When cron launch /home/admin/MONGODB-BACKUP/mongodump.sh, PATH is NOT defined. So your script and all scripts call by it do not know where to find commands, as kubectl.
With admin, do :
Code:
echo $PATH
And in your script, add at the beginning (under #!/bin/sh) :
cron does not cd into the dir you want, so first you need to cd or use full path inside your scripts (instead of relative path). Also you may need to use mkdir with -p.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.