Mount in script drives me crazy
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am using some backup script I found somewhere and modified it to my needs but I have problems with mounting shared folder. Here is problematic part of script:
#!/bin/bash
#
# Backup folder to storage
# Check if command is finished without errors
function startit()
command_output=$(eval $1)
output_value=$?
if [ $output_value != 0 ]; then
echo "Failure!" >> /var/log/backup/sharefiles/webserver_$TIMES.log
exit -1
else
echo "Success!" >> /var/log/backup/sharefiles/webserver_$TIMES.log
fi
return $output_value
# Parameters
SHARED="/folder/shared/"
MOUNTPOINT="//server.some.address/backup/SharedFiles/"
TARGET="/backup/shared/"
TIMES=`date '+%Y.%m.%d_%H'`
TIMESTART=`date '+%Y.%m.%d %H:%M'`
USERNAME="someusername"
PASS="somepass"
# BackupStart
echo "Backup is started" >> /var/log/backup/sharefiles/webserver_$TIMES.log
echo "Now is $TIMESTART" >> /var/log/backup/sharefiles/webserver_$TIMES.log
# Mount shared folder to server
echo "Mount Storage share" >> /var/log/backup/sharefiles/webserver_$TIMES.log
startit "mount -t cifs -o user=$USERNAME,password=$PASS $MOUNTPOINT $TARGET"
Every time I start script it shows that mount is failed and I get error
mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
My first guess was that I messed something with variables so I set
startit "mount -t cifs -o user=someusername,password=somepass //server.some.address/backup/SharedFiles/ /backup/shared/"
instead
startit "mount -t cifs -o user=$USERNAME,password=$PASS $MOUNTPOINT $TARGET"
And it works fine when I start script manually. BUT. Then I created cron job and error is back?!
What is even more weird on another server I have exact same script on exact same version of Linux (Centos 7) and it works flawlessly with same shared folder.
Does anyone have any idea?
shell-script centos mount cron
add a comment |Â
up vote
0
down vote
favorite
I am using some backup script I found somewhere and modified it to my needs but I have problems with mounting shared folder. Here is problematic part of script:
#!/bin/bash
#
# Backup folder to storage
# Check if command is finished without errors
function startit()
command_output=$(eval $1)
output_value=$?
if [ $output_value != 0 ]; then
echo "Failure!" >> /var/log/backup/sharefiles/webserver_$TIMES.log
exit -1
else
echo "Success!" >> /var/log/backup/sharefiles/webserver_$TIMES.log
fi
return $output_value
# Parameters
SHARED="/folder/shared/"
MOUNTPOINT="//server.some.address/backup/SharedFiles/"
TARGET="/backup/shared/"
TIMES=`date '+%Y.%m.%d_%H'`
TIMESTART=`date '+%Y.%m.%d %H:%M'`
USERNAME="someusername"
PASS="somepass"
# BackupStart
echo "Backup is started" >> /var/log/backup/sharefiles/webserver_$TIMES.log
echo "Now is $TIMESTART" >> /var/log/backup/sharefiles/webserver_$TIMES.log
# Mount shared folder to server
echo "Mount Storage share" >> /var/log/backup/sharefiles/webserver_$TIMES.log
startit "mount -t cifs -o user=$USERNAME,password=$PASS $MOUNTPOINT $TARGET"
Every time I start script it shows that mount is failed and I get error
mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
My first guess was that I messed something with variables so I set
startit "mount -t cifs -o user=someusername,password=somepass //server.some.address/backup/SharedFiles/ /backup/shared/"
instead
startit "mount -t cifs -o user=$USERNAME,password=$PASS $MOUNTPOINT $TARGET"
And it works fine when I start script manually. BUT. Then I created cron job and error is back?!
What is even more weird on another server I have exact same script on exact same version of Linux (Centos 7) and it works flawlessly with same shared folder.
Does anyone have any idea?
shell-script centos mount cron
3
I kinda wonder why you bother with a function at all. The function and theeval
in it just adds complexity (and you are possibly getting the quoting wrong). Just do the mount in the main part of the script.
â Kusalananda
Apr 27 at 8:34
1
Do the target directory always exist? I think you should start debugging: add ` -x` on the first line. Check output. Print more. Shell is not forgiving about small errors.
â Giacomo Catenazzi
Apr 27 at 8:44
I have some delete job after mount and I just want to make sure everything is where it should be before that. I know it complicates things but didn't know how to simplify everything. Also target dir always exist and it is always the same one. Will try both suggestions. Hope it will help.
â Ivica Vujovic
Apr 27 at 13:11
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using some backup script I found somewhere and modified it to my needs but I have problems with mounting shared folder. Here is problematic part of script:
#!/bin/bash
#
# Backup folder to storage
# Check if command is finished without errors
function startit()
command_output=$(eval $1)
output_value=$?
if [ $output_value != 0 ]; then
echo "Failure!" >> /var/log/backup/sharefiles/webserver_$TIMES.log
exit -1
else
echo "Success!" >> /var/log/backup/sharefiles/webserver_$TIMES.log
fi
return $output_value
# Parameters
SHARED="/folder/shared/"
MOUNTPOINT="//server.some.address/backup/SharedFiles/"
TARGET="/backup/shared/"
TIMES=`date '+%Y.%m.%d_%H'`
TIMESTART=`date '+%Y.%m.%d %H:%M'`
USERNAME="someusername"
PASS="somepass"
# BackupStart
echo "Backup is started" >> /var/log/backup/sharefiles/webserver_$TIMES.log
echo "Now is $TIMESTART" >> /var/log/backup/sharefiles/webserver_$TIMES.log
# Mount shared folder to server
echo "Mount Storage share" >> /var/log/backup/sharefiles/webserver_$TIMES.log
startit "mount -t cifs -o user=$USERNAME,password=$PASS $MOUNTPOINT $TARGET"
Every time I start script it shows that mount is failed and I get error
mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
My first guess was that I messed something with variables so I set
startit "mount -t cifs -o user=someusername,password=somepass //server.some.address/backup/SharedFiles/ /backup/shared/"
instead
startit "mount -t cifs -o user=$USERNAME,password=$PASS $MOUNTPOINT $TARGET"
And it works fine when I start script manually. BUT. Then I created cron job and error is back?!
What is even more weird on another server I have exact same script on exact same version of Linux (Centos 7) and it works flawlessly with same shared folder.
Does anyone have any idea?
shell-script centos mount cron
I am using some backup script I found somewhere and modified it to my needs but I have problems with mounting shared folder. Here is problematic part of script:
#!/bin/bash
#
# Backup folder to storage
# Check if command is finished without errors
function startit()
command_output=$(eval $1)
output_value=$?
if [ $output_value != 0 ]; then
echo "Failure!" >> /var/log/backup/sharefiles/webserver_$TIMES.log
exit -1
else
echo "Success!" >> /var/log/backup/sharefiles/webserver_$TIMES.log
fi
return $output_value
# Parameters
SHARED="/folder/shared/"
MOUNTPOINT="//server.some.address/backup/SharedFiles/"
TARGET="/backup/shared/"
TIMES=`date '+%Y.%m.%d_%H'`
TIMESTART=`date '+%Y.%m.%d %H:%M'`
USERNAME="someusername"
PASS="somepass"
# BackupStart
echo "Backup is started" >> /var/log/backup/sharefiles/webserver_$TIMES.log
echo "Now is $TIMESTART" >> /var/log/backup/sharefiles/webserver_$TIMES.log
# Mount shared folder to server
echo "Mount Storage share" >> /var/log/backup/sharefiles/webserver_$TIMES.log
startit "mount -t cifs -o user=$USERNAME,password=$PASS $MOUNTPOINT $TARGET"
Every time I start script it shows that mount is failed and I get error
mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
My first guess was that I messed something with variables so I set
startit "mount -t cifs -o user=someusername,password=somepass //server.some.address/backup/SharedFiles/ /backup/shared/"
instead
startit "mount -t cifs -o user=$USERNAME,password=$PASS $MOUNTPOINT $TARGET"
And it works fine when I start script manually. BUT. Then I created cron job and error is back?!
What is even more weird on another server I have exact same script on exact same version of Linux (Centos 7) and it works flawlessly with same shared folder.
Does anyone have any idea?
shell-script centos mount cron
asked Apr 27 at 8:27
Ivica Vujovic
1
1
3
I kinda wonder why you bother with a function at all. The function and theeval
in it just adds complexity (and you are possibly getting the quoting wrong). Just do the mount in the main part of the script.
â Kusalananda
Apr 27 at 8:34
1
Do the target directory always exist? I think you should start debugging: add ` -x` on the first line. Check output. Print more. Shell is not forgiving about small errors.
â Giacomo Catenazzi
Apr 27 at 8:44
I have some delete job after mount and I just want to make sure everything is where it should be before that. I know it complicates things but didn't know how to simplify everything. Also target dir always exist and it is always the same one. Will try both suggestions. Hope it will help.
â Ivica Vujovic
Apr 27 at 13:11
add a comment |Â
3
I kinda wonder why you bother with a function at all. The function and theeval
in it just adds complexity (and you are possibly getting the quoting wrong). Just do the mount in the main part of the script.
â Kusalananda
Apr 27 at 8:34
1
Do the target directory always exist? I think you should start debugging: add ` -x` on the first line. Check output. Print more. Shell is not forgiving about small errors.
â Giacomo Catenazzi
Apr 27 at 8:44
I have some delete job after mount and I just want to make sure everything is where it should be before that. I know it complicates things but didn't know how to simplify everything. Also target dir always exist and it is always the same one. Will try both suggestions. Hope it will help.
â Ivica Vujovic
Apr 27 at 13:11
3
3
I kinda wonder why you bother with a function at all. The function and the
eval
in it just adds complexity (and you are possibly getting the quoting wrong). Just do the mount in the main part of the script.â Kusalananda
Apr 27 at 8:34
I kinda wonder why you bother with a function at all. The function and the
eval
in it just adds complexity (and you are possibly getting the quoting wrong). Just do the mount in the main part of the script.â Kusalananda
Apr 27 at 8:34
1
1
Do the target directory always exist? I think you should start debugging: add ` -x` on the first line. Check output. Print more. Shell is not forgiving about small errors.
â Giacomo Catenazzi
Apr 27 at 8:44
Do the target directory always exist? I think you should start debugging: add ` -x` on the first line. Check output. Print more. Shell is not forgiving about small errors.
â Giacomo Catenazzi
Apr 27 at 8:44
I have some delete job after mount and I just want to make sure everything is where it should be before that. I know it complicates things but didn't know how to simplify everything. Also target dir always exist and it is always the same one. Will try both suggestions. Hope it will help.
â Ivica Vujovic
Apr 27 at 13:11
I have some delete job after mount and I just want to make sure everything is where it should be before that. I know it complicates things but didn't know how to simplify everything. Also target dir always exist and it is always the same one. Will try both suggestions. Hope it will help.
â Ivica Vujovic
Apr 27 at 13:11
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f440362%2fmount-in-script-drives-me-crazy%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
3
I kinda wonder why you bother with a function at all. The function and the
eval
in it just adds complexity (and you are possibly getting the quoting wrong). Just do the mount in the main part of the script.â Kusalananda
Apr 27 at 8:34
1
Do the target directory always exist? I think you should start debugging: add ` -x` on the first line. Check output. Print more. Shell is not forgiving about small errors.
â Giacomo Catenazzi
Apr 27 at 8:44
I have some delete job after mount and I just want to make sure everything is where it should be before that. I know it complicates things but didn't know how to simplify everything. Also target dir always exist and it is always the same one. Will try both suggestions. Hope it will help.
â Ivica Vujovic
Apr 27 at 13:11