Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old May 3rd, 2008, 11:41 AM
Weekend Coder Weekend Coder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 77 Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 39 m 33 sec
Reputation Power: 21
Shell Script Permissions Issue

I've been having problems with LogRotate, so while I troubleshoot them, I've written a little shell script to rotate my qmail scanner log.
Code:
#!/bin/bash

LOGFILE=/var/spool/qmailscan/qmail-queue.log

tar -cvvf ~/qmail-queue.backup.tar.gz $LOGFILE
echo "" > $LOGFILE
I've also added a cron job to run it...
Code:
#rotate logs every saturday at 12am
0 0 * * * /var/qmail/bin/qmail-queue-log-rotate.sh 2> /dev/null
Now, when I try to run it from the command line, even as root, I get this:
Quote:
[root@localhost bin]# ./qmail-queue-log-rotate.sh
-bash: ./qmail-queue-log-rotate.sh: Permission denied
What am I doing wrong?

Reply With Quote
  #2  
Old May 3rd, 2008, 12:28 PM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2007
Location: outside Washington DC
Posts: 610 fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 15 h 24 m 48 sec
Reputation Power: 177
what user is running the script? Is it root?
If not, you need to do whatever your distro wants, sudo or equivalent

Reply With Quote
  #3  
Old May 3rd, 2008, 12:50 PM
Weekend Coder Weekend Coder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 77 Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 39 m 33 sec
Reputation Power: 21
Quote:
Originally Posted by fishtoprecords
what user is running the script? Is it root?
If not, you need to do whatever your distro wants, sudo or equivalent
Owner is root.

Reply With Quote
  #4  
Old May 3rd, 2008, 01:13 PM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2007
Location: outside Washington DC
Posts: 610 fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 15 h 24 m 48 sec
Reputation Power: 177
can you execute the commands by hand as root?
You could have 444 or some equivalent protection that does not allow root to write

Reply With Quote
  #5  
Old May 3rd, 2008, 01:23 PM
Weekend Coder Weekend Coder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 77 Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 39 m 33 sec
Reputation Power: 21
I changed the permissions, now I don't get "permission denied", here's the output:
Quote:
[root@localhost qmailscan]# ./qmail-queue-rotate.sh
tar: Removing leading `/' from member names
-rw------- qscand/vchkpw 21827 2008-05-03 11:21:04 var/spool/qmailscan/qmail-queue.log
It does seem to be "zeroing" out the log file. But it does not generate the file qmail-queue.backup.tar.gz

Last edited by Weekend Coder : May 3rd, 2008 at 01:30 PM.

Reply With Quote
  #6  
Old May 3rd, 2008, 02:29 PM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2007
Location: outside Washington DC
Posts: 610 fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 15 h 24 m 48 sec
Reputation Power: 177
Do you really have it

Quote:
tar -cvvf


rather than something like tar -cvzf
create verbose gZip file

Reply With Quote
  #7  
Old May 3rd, 2008, 02:32 PM
Weekend Coder Weekend Coder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 77 Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 39 m 33 sec
Reputation Power: 21
Quote:
Originally Posted by fishtoprecords
Do you really have it



rather than something like tar -cvzf
create verbose gZip file
Can you provide example?

Reply With Quote
  #8  
Old May 3rd, 2008, 02:37 PM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2007
Location: outside Washington DC
Posts: 610 fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 15 h 24 m 48 sec
Reputation Power: 177
I just did. Your upthread posting says
Quote:
tar -cvvf ~/qmail-queue.backup.tar.gz $LOGFILE



which does not work for me. you are missing the z, instead you have to v

Quote:
tar -cvzf ~/qmail-queue.backup.tar.gz $LOGFILE



Before you try to debug a shell script, make sure that the commands work manually
Comments on this post
Weekend Coder agrees: Thanks...

Reply With Quote
  #9  
Old May 3rd, 2008, 03:14 PM
Weekend Coder Weekend Coder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 77 Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level)Weekend Coder User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 39 m 33 sec
Reputation Power: 21
Oh, I see. Also, I changed the tilde (~).
Quote:
tar -cvzf ./qmail-queue.backup.tar.gz $LOGFILE
THANKS!

Reply With Quote
  #10  
Old May 3rd, 2008, 03:19 PM
lnxgeek lnxgeek is offline
I AM A GOLDEN GOD
Dev Shed God (5000 - 5499 posts)
 
Join Date: Apr 2003
Location: cannot find symbol: method showLocation()
Posts: 5,278 lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level)lnxgeek User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 21 h 17 m 36 sec
Reputation Power: 564
I was wondering about that; the ~ tilde represents the user's home directory, in this case I suppose it would be /root.

I recommend using the full path to the file when using scripts like this, especially in conjunction with cron.
__________________
BookMooch.com : Give books away. Get books you want.

Reply With Quote
  #11  
Old May 3rd, 2008, 03:20 PM
fishtoprecords's Avatar
fishtoprecords fishtoprecords is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2007
Location: outside Washington DC
Posts: 610 fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level)fishtoprecords User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 15 h 24 m 48 sec
Reputation Power: 177
yes, ~ in cron scripts can be confusing. Much more obvious to be explicit

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Shell Script Permissions Issue


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members