Mailing List Archive

cron jobs unable to smbmount
Hi

The company I work for has a WinNT server with a backup tape and a
scheduled backup program.

I've built a Gentoo server for my department, and I've written some
little backup scripts to smbmount a share on that NT server and to copy
some files there in order to have a tape backup of important files
residing on this Gentoo box on the tape unit on that NT box

But I always get an e-mail from the system telling me that it was unable
to smbmount the share I've chosen

Weird, because when I run this script directly from the command line, it
works perfectly

Any permissions issue I might be unaware?

Thanks
Francisco

--
gentoo-user@gentoo.org mailing list
Re: cron jobs unable to smbmount [ In reply to ]
Billy Holmes wrote:

> Jason Cooper wrote:
>
>> needs. try wrapping it with 'sh scriptname'. That may work.
>
>
> it could also be that he needs to source his /etc/profile before he
> does the smb command to mount the volume.
>
None of them worked. Still not able to smbmount. Going to look further
into the permissions of the user "cron" (?!?)

Thanks anyway!

Francisco

--
gentoo-user@gentoo.org mailing list
Re: cron jobs unable to smbmount [ In reply to ]
Francisco J. A. Ares (francisco.ares@altecvision.com) scribbled:
> Hi
>
> The company I work for has a WinNT server with a backup tape and a
> scheduled backup program.
>
> I've built a Gentoo server for my department, and I've written some
> little backup scripts to smbmount a share on that NT server and to copy
> some files there in order to have a tape backup of important files
> residing on this Gentoo box on the tape unit on that NT box
>
> But I always get an e-mail from the system telling me that it was unable
> to smbmount the share I've chosen
>
> Weird, because when I run this script directly from the command line, it
> works perfectly
>
> Any permissions issue I might be unaware?

When I run into these problems it is almost always a bash shell issue.
eg. when cron runs the script, it is not in a shell. When you run it,
it is from within a shell. The shell provides something the script
needs. try wrapping it with 'sh scriptname'. That may work.


hth,

Cooper.

--
gentoo-user@gentoo.org mailing list
Re: cron jobs unable to smbmount [ In reply to ]
Lode Vanstechelman wrote:

> Francisco J. A. Ares wrote:
> | None of them worked. Still not able to smbmount. Going to look further
> | into the permissions of the user "cron" (?!?)
>
> When crontab executes something, it has NO environment variables. This
> means, no PATH-variable and others are known. Perhaps your script uses
> some of these variables?


This is an example of those backup scripts:

#!/bin/bash
source /etc/profile
/usr/bin/smbmount //192.2.1.151/Departaments
/mnt/NT_SERVER2/Departaments/ -o `cat /home/$1/.authSMB` >/dev/null
2>/dev/null
/bin/tar -Pcf "/gentoo1/Files/OpenOffice/OpenOffice_$1.tar"
/gentoo1/Files/OpenOffice/$1/*
/bin/bzip2 --best /gentoo1/Files/OpenOffice_$1.tar
rm -f
/mnt/NT_SERVER2/Departaments/Engineering/OpenOffice/$1/OpenOffice_$1.tar.bz2
cp -f /gentoo1/Files/OpenOffice/OpenOffice_$1.*
/mnt/NT_SERVER2/Departaments/Files/OpenOffice/$1/
rm -f /gentoo1/Files/OpenOffice/OpenOffice_$1.tar.bz2
/usr/bin/smbumount /mnt/NT_SERVER2/Departaments/ >/dev/null 2>/dev/null


the crontab entries are as follows (they start at 22:00h = 10:00pm as
the NT server backup to tape starts at 2300h = 11:00pm):

0 22 * * 1-5 /bin/bash /root/bin/backup <user1>
5 22 * * 1-5 /bin/bash /root/bin/backup <user2>
10 22 * * 1-5 /bin/bash /root/bin/backup <user3>

where user1, user2 and user3 are real user names ( $1 parameters)

When I run this script as root, everithing is fine

As you can see, there's a file inside the home directory of every user
with his(her) login on the NT_SERVER2 server. The access to this file
has already been tested, I've made a simple test to copy those files to
the root directory by a cron job and it worked fine.

I know the script is a bad backup procedure, I promisse I'll get a
better one when this one gets to work.

Thankyou all
Francisco

--
gentoo-user@gentoo.org mailing list
Re: cron jobs unable to smbmount [ In reply to ]
Jason Cooper wrote:

> needs. try wrapping it with 'sh scriptname'. That may work.

it could also be that he needs to source his /etc/profile before he does
the smb command to mount the volume.

--
gentoo-user@gentoo.org mailing list
Re: cron jobs unable to smbmount [ In reply to ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Francisco J. A. Ares wrote:
| None of them worked. Still not able to smbmount. Going to look further
| into the permissions of the user "cron" (?!?)

When crontab executes something, it has NO environment variables. This
means, no PATH-variable and others are known. Perhaps your script uses
some of these variables?

- --
~ Homepage:
~ http://lvsteche.webhop.net
~ Public PGP-Key is available from:
~ http://lvsteche.webhop.net/PublicPGP.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBSGME0PFi0x8ZCzwRAugYAJ9bXGrMqW+G+WTTtNRVlPnaYEKiEgCeNeaF
wOH2PyjAt9YGRqRp9uWtvXc=
=dNWg
-----END PGP SIGNATURE-----

--
gentoo-user@gentoo.org mailing list
Re: cron jobs unable to smbmount [ In reply to ]
Francisco J. A. Ares wrote:

> This is an example of those backup scripts:

is cron running as root?

if so:

1) create a root shell
2) unset all your environment variables
3) set *only* the environment vars that cron sets[1]
4) run your backup script

This should give you an environment that is close to what the cronjob is
running as.

[1] you can see the cron environment by easily creating a new cronjob
that runs every minute, that just has the command "set" or "env" in it.
This will email you the cron's environment variables. Onces you have it,
remove that cronjob.

--
gentoo-user@gentoo.org mailing list
Re: cron jobs unable to smbmount [ In reply to ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

| /usr/bin/smbmount //192.2.1.151/Departaments
| /mnt/NT_SERVER2/Departaments/ -o `cat /home/$1/.authSMB` >/dev/null
| 2>/dev/null

Could you run the script (with crontab) without the output-redirection
to /dev/null and post the output here?
Perhaps that will help us solve your problem.

Are you sure you gave the correct argument to the script? Otherwise the
$1 could be the problem. Perhaps you should try to run the script with
the $1 variable replaced by a real string.

- --
~ Homepage:
~ http://lvsteche.webhop.net
~ Public PGP-Key is available from:
~ http://lvsteche.webhop.net/PublicPGP.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBSHY90PFi0x8ZCzwRAuXvAKCb3/7TLzcu9CpYnJmbJc2uebp8ZQCfVEi8
CsbnX/cOgupGoQEAWWYmNmA=
=nEi9
-----END PGP SIGNATURE-----

--
gentoo-user@gentoo.org mailing list
Re: cron jobs unable to smbmount [ In reply to ]
Lode Vanstechelman wrote:

> | /usr/bin/smbmount //192.2.1.151/Departaments
> | /mnt/NT_SERVER2/Departaments/ -o `cat /home/$1/.authSMB` >/dev/null
> | 2>/dev/null
>
> Could you run the script (with crontab) without the output-redirection
> to /dev/null and post the output here?
> Perhaps that will help us solve your problem.
>
> Are you sure you gave the correct argument to the script? Otherwise the
> $1 could be the problem. Perhaps you should try to run the script with
> the $1 variable replaced by a real string.
>
the argument works fine, I have already put some extra lines in the
script for that kind of diagnosis

removing the "/dev/null" , I've got this message:

13398: session request to 192.2.1.151 failed (Called name not present)
13398: session request to 192 failed (Called name not present)
13398: session setup failed: ERRDOS - ERRnoaccess (Access denied.)
SMB connection failed
cp: impossible to create common file `/mnt/NT_SERVER2/Departaments/Engineering/OpenOffice/fares/OpenOffice_fares.tar.bz2': File or Directory not found


As you can see, user name "fares" is correctly being passed as a
parameter to the cron job.

Thanks for your help
Francisco

--
gentoo-user@gentoo.org mailing list
Re: cron jobs unable to smbmount [ In reply to ]
Francisco J. A. Ares wrote:

> I know the script is a bad backup procedure, I promisse I'll get a
> better one when this one gets to work.
>
> Thankyou all
> Francisco
>

You cannot go wrong with Amanda, as a backup utility...


James



--
gentoo-user@gentoo.org mailing list
Re: cron jobs unable to smbmount [ In reply to ]
On Wednesday 15 September 2004 19:36, Francisco J. A. Ares wrote:
> Lode Vanstechelman wrote:
> > | /usr/bin/smbmount //192.2.1.151/Departaments
> > | /mnt/NT_SERVER2/Departaments/ -o `cat /home/$1/.authSMB`
> > | >/dev/null 2>/dev/null
> >
> > Could you run the script (with crontab) without the
> > output-redirection to /dev/null and post the output here?
> > Perhaps that will help us solve your problem.
> >
> > Are you sure you gave the correct argument to the script? Otherwise
> > the $1 could be the problem. Perhaps you should try to run the
> > script with the $1 variable replaced by a real string.
>
> the argument works fine, I have already put some extra lines in the
> script for that kind of diagnosis
>
> removing the "/dev/null" , I've got this message:
>
> 13398: session request to 192.2.1.151 failed (Called name not
> present) 13398: session request to 192 failed (Called name not
> present) 13398: session setup failed: ERRDOS - ERRnoaccess (Access
> denied.) SMB connection failed
> cp: impossible to create common file
> `/mnt/NT_SERVER2/Departaments/Engineering/OpenOffice/fares/OpenOffice
>_fares.tar.bz2': File or Directory not found
>
>
> As you can see, user name "fares" is correctly being passed as a
> parameter to the cron job.
>
Are you sure about "Departaments", an not "Depart(e)ment" ? Is it
spelled as it is in filesystem?

Maybe is not complainign about "fares".

HTH
Francesco

--
Linux Version 2.6.8.1, Compiled #1 Wed Sep 15 21:29:54 CEST 2004
One 1.53GHz AMD Athlon XP Processor, 1.5GB RAM, 3022.84 Bogomips Total
macula.fastwebnet.it

--
gentoo-user@gentoo.org mailing list
Re: Re: cron jobs unable to smbmount [ In reply to ]
Francesco Talamona wrote:

>On Wednesday 15 September 2004 19:36, Francisco J. A. Ares wrote:
>
>
>>Lode Vanstechelman wrote:
>>
>>
>>>| /usr/bin/smbmount //192.2.1.151/Departaments
>>>| /mnt/NT_SERVER2/Departaments/ -o `cat /home/$1/.authSMB`
>>>| >/dev/null 2>/dev/null
>>>
>>>Could you run the script (with crontab) without the
>>>output-redirection to /dev/null and post the output here?
>>>Perhaps that will help us solve your problem.
>>>
>>>Are you sure you gave the correct argument to the script? Otherwise
>>>the $1 could be the problem. Perhaps you should try to run the
>>>script with the $1 variable replaced by a real string.
>>>
>>>
>>the argument works fine, I have already put some extra lines in the
>>script for that kind of diagnosis
>>
>>removing the "/dev/null" , I've got this message:
>>
>>13398: session request to 192.2.1.151 failed (Called name not
>>present) 13398: session request to 192 failed (Called name not
>>present) 13398: session setup failed: ERRDOS - ERRnoaccess (Access
>>denied.) SMB connection failed
>>cp: impossible to create common file
>>`/mnt/NT_SERVER2/Departaments/Engineering/OpenOffice/fares/OpenOffice
>>_fares.tar.bz2': File or Directory not found
>>
>>
>>As you can see, user name "fares" is correctly being passed as a
>>parameter to the cron job.
>>
>>
>>
>Are you sure about "Departaments", an not "Depart(e)ment" ? Is it
>spelled as it is in filesystem?
>
>Maybe is not complainign about "fares".
>
>HTH
> Francesco
>
>

Thanks, Francesco, but it was just a mistake on the posting, the
original, as I said before, works ok when run "by hand" when I log as root

--
gentoo-user@gentoo.org mailing list
Re: Re: cron jobs unable to smbmount [ In reply to ]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

|>> 13398: session request to 192.2.1.151 failed (Called name no
|>> present) 13398: session request to 192 failed (Called name not
|>> present) 13398: session setup failed: ERRDOS - ERRnoaccess (Access
|>> denied.) SMB connection failed
|>> cp: impossible to create common file
|>> `/mnt/NT_SERVER2/Departaments/Engineering/OpenOffice/fares/OpenOffice
|>> _fares.tar.bz2': File or Directory not found

When crontab runs the script, as what user does it run? Is it the same
one as when you run the script by hand? It could be that when you run
the script by hand that you have access on the samba shares, but that
the user that is running the crontab script does not have access.

Lode
- --
~ Homepage:
~ http://lvsteche.webhop.net
~ Public PGP-Key is available from:
~ http://lvsteche.webhop.net/PublicPGP.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBSYqQ0PFi0x8ZCzwRAoAfAJ0QjbbnU1JY9jJCOAJDSOeQnB3ZHgCeLihb
ET2KYg5MY1BkpfBP5eBywE8=
=AyaV
-----END PGP SIGNATURE-----

--
gentoo-user@gentoo.org mailing list
Re: Re: cron jobs unable to smbmount [ In reply to ]
Lode Vanstechelman wrote:

> |>> 13398: session request to 192.2.1.151 failed (Called name no
> |>> present) 13398: session request to 192 failed (Called name not
> |>> present) 13398: session setup failed: ERRDOS - ERRnoaccess (Access
> |>> denied.) SMB connection failed
> |>> cp: impossible to create common file
> |>> `/mnt/NT_SERVER2/Departaments/Engineering/OpenOffice/fares/OpenOffice
> |>> _fares.tar.bz2': File or Directory not found
>
> When crontab runs the script, as what user does it run? Is it the same
> one as when you run the script by hand? It could be that when you run
> the script by hand that you have access on the samba shares, but that
> the user that is running the crontab script does not have access.
>
> Lode
> --


I've already thought about that, but I really don't know what user is
"cron" , I think its "root", but I'm not sure. And I don't even know
where to find this information, already googled a lot of pages, perhaps
I'm using bad keywords.

Thanks
Francisco


--
gentoo-user@gentoo.org mailing list
Re: Re: cron jobs unable to smbmount [ In reply to ]
Doesn't cron run the job as whatever user is specified in the
/etc/crontab file? And if you place the file into one of the cron job
directories (/etc/cron.daily, etc.), doesn't the job run as root
automatically?

Matt


On Thu, 16 Sep 2004 13:39:37 +0000, Francisco J. A. Ares
<francisco.ares@altecvision.com> wrote:
> Lode Vanstechelman wrote:
>
> > |>> 13398: session request to 192.2.1.151 failed (Called name no
> > |>> present) 13398: session request to 192 failed (Called name not
> > |>> present) 13398: session setup failed: ERRDOS - ERRnoaccess (Access
> > |>> denied.) SMB connection failed
> > |>> cp: impossible to create common file
> > |>> `/mnt/NT_SERVER2/Departaments/Engineering/OpenOffice/fares/OpenOffice
> > |>> _fares.tar.bz2': File or Directory not found
> >
> > When crontab runs the script, as what user does it run? Is it the same
> > one as when you run the script by hand? It could be that when you run
> > the script by hand that you have access on the samba shares, but that
> > the user that is running the crontab script does not have access.
> >
> > Lode
> > --
>
>
> I've already thought about that, but I really don't know what user is
> "cron" , I think its "root", but I'm not sure. And I don't even know
> where to find this information, already googled a lot of pages, perhaps
> I'm using bad keywords.
>
> Thanks
> Francisco
>
>
>
>
> --
> gentoo-user@gentoo.org mailing list
>
>

--
gentoo-user@gentoo.org mailing list