I'm trying to mount a cifs partition from a Windows Server 2012 Essentials to my Ubuntu server 16.04. When i run the command /sbin/mount.cifs //$/Dropbox/0-sbezavel02/dados/ /dados/sbezavel02 -o vers=2.1,username=foo,password='foobar' it works fine and i am able to copy the files from the windows server (IP to my Linux server. I need to do this in a script for my backup routine. However, i can't make it work in my shell script. The script is not being able to run the command /sbin/mount.cifs //$/Dropbox/0-sbezavel02/dados/ /dados/sbezavel02 -o vers=2.1,username=foo,password='foobar'. I know this because if i have the path already mouted, the backup will run smoothly, no problem. But, if i haven't, the backup will not find the path and it won't work. I also do a checkup to see if it mounted alright with the following command right after mounting:

cat /dados/sbezavel02/montado-sbezavel01.txt >> /dados/conf-sbezavel01.txt

And it also doesn't work... so this part of my script goes like this:

/sbin/mount.cifs //$/Dropbox/0-sbezavel02/dados/ /dados/sbezavel02 -o vers=2.1,username=foo,password='foobar' 1>> $log_backup 2>> $log_erro
sleep 10

cat /dados/sbezavel02/montado-sbezavel01.txt >> /dados/conf-sbezavel01.txt

Anyone knows what might be the problem here?

  • Does the back-up script run with root privileges? These will normally be needed to mount a file system, or to use any of the utilities in /sbin. – AFH Mar 20 '18 at 20:26
  • Yes, it is running with root privileges. – user3808300 Mar 20 '18 at 20:33
  • 1
    Is the back-up script running under cron? Its run environment can be very different from the normal bash interactive environment. – AFH Mar 20 '18 at 20:44
  • Yes, it is. It's and the cron is setup like this: #backup-1a5 00 21 * * 1-5 . /dados/bin/backup-completo-1a5 1>/dev/null – user3808300 Mar 20 '18 at 20:59
  • I hope that #backup-1a5 is on the line above the rest of the entry. A quick test shows that . does not work as a crontab command: if you redirect to a file and add 2>&1 to the end of the command line, you'll see the error message. – AFH Mar 20 '18 at 22:23

Your Answer

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

Browse other questions tagged or ask your own question.