LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-24-2004, 05:14 AM   #1
esasse
LQ Newbie
 
Registered: Nov 2004
Location: Americana, SP - Brazil
Distribution: Fedora
Posts: 17

Rep: Reputation: 0
Permissions in cron


I have a very simple backup script. When I run it from command line it works well, so I created a symbolic link to it in cron.daily.

The script is executed, but a part of it, that calls the backup application for the Firebird database doesn't work.

I think it is something with permissions, since the backup runs fine when I'm looged as root.

Scripts executed by cron runs under a specific account? How does it work? Where can I find more information about it?
 
Old 11-24-2004, 05:17 AM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
You may have to set the paths to search for executables in the script since this will most likely not be set, or you can specify the full path to all programs called from the script (instead of mybackup.sh use /usr/local/bin/mybackup.sh).


Håkan
 
Old 11-24-2004, 07:45 AM   #3
esasse
LQ Newbie
 
Registered: Nov 2004
Location: Americana, SP - Brazil
Distribution: Fedora
Posts: 17

Original Poster
Rep: Reputation: 0
That's it! Thanks!

Since I can start the application from anywhere while I'm in console, I thought I didn't need to specify the full path in the script.

But suppose I want the scripts to use the search paths, how can I do it?
 
Old 11-25-2004, 06:20 AM   #4
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
You need to set the path at the beginning of your script. The environment variable $PATH contains a comma-separated list of the directories that are to be searched for executables. Type echo $PATH to see what directories are currently in your $PATH.

You set it like this:
PATH=dir1:dir2:dir2
...or for a more real-world like example:
PATH=/bin:/usr/bin:/usr/local/bin:~/bin

You can also tack on a directory to the existing $PATH by including $PATH itself in the list of directories to be used:
PATH=$PATH:/opt/myownstuff/bin:/home/jenny/bin

Simply adding the PATH= entry with the directories you need at the top of the script, after the magic line (#!/bin/bash or whatever) but before any real stuff gets done should let you use the programs in the directories you specified without using their full paths.

On a related but not really relevant note, I usually use this in my ~/.bashrc:
alias path='echo -e ${PATH//:/\\n}'
This provides me with the command path that will print the current $PATH in a more readable format - one directory per line.

Håkan
 
Old 11-25-2004, 07:00 AM   #5
esasse
LQ Newbie
 
Registered: Nov 2004
Location: Americana, SP - Brazil
Distribution: Fedora
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks a lot!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
cron.allow and cron.deny in slackware? tl64 Slackware 5 10-13-2005 09:44 PM
root cron permissions question bjdea1 Linux - General 6 07-10-2004 12:39 PM
[cron][mdk9.1]cron deamon seems to ignore some task... yannrichet Linux - Newbie 5 06-26-2003 09:57 AM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 02:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration