Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My crontab (running as user) contains the following command

00-59 00-23 * * *  /usr/bin/smbget -R smb:// -u USER -p PASSWORD

But I am getting an error as

You don't have enough permissions to access smb://

But the same command I can execute (running as user) from command line.

How to give permissions to crontab to solve the issue?

share|improve this question

migrated from Jun 9 '11 at 14:14

This question came from our site for professional and enthusiast programmers.

maybe you should ask on – Elzo Valugi Jun 9 '11 at 6:50

I had the same problem, and it took me about 6 hours to work out the answer. You get it for free:

When you are logged in properly, you will have an environment variable USER=root - this will not be in your environment when you run a job from crontab.

To set an environment variable for one command in crontab, simply put it directly before your command (i.e. after the time/day specification). So in your case:

00-59 00-23 * * *  USER=root /usr/bin/smbget -R smb:// -u USER -p PASSWORD
share|improve this answer
+1 You get a free upvote. – Tom Wijsman Aug 25 '11 at 23:47

I would set up Autofs to take care of mounting the SMB file system. You can use a credentials file to keep it a bit more secure. From there, your cronjob is simply cp /mnt/smbshare/data /home/whomever/whereever.

Autofs won't leave the SMB share mounted forever, and it will help you eliminate the hassle of trying to figure out those SMB tools inside cron.

share|improve this answer

You must log in to answer this question.