SunQuest
           UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX 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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 22nd, 2004, 02:43 PM
xxbenxx xxbenxx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 8 xxbenxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Crontab and (permission denied)

Hello all,

Im trying to schedule a java program to run a few times daily with crontab on UNIX. The program will run and produce the correct output(i know because it emails the output to me), but whenever I try to append the output in an existing text file, i get an error that looks like :

java.io.FileNotFoundException: /usr/local/home/myid/public_html/Forecast/file.txt (Permission denied)

I tried to change the permission of file.txt to always use my id (or something like this...i read it online and attempted it but I did not have the permission to change to it). Any ideas?

Reply With Quote
  #2  
Old November 22nd, 2004, 02:47 PM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
if you don't own the file and you don't have the permissions to modify it's ownership, then you're stuck - so why not just create a new file somewhere, then use chmod to set the permissions you want.

christo

Reply With Quote
  #3  
Old November 22nd, 2004, 02:52 PM
xxbenxx xxbenxx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 8 xxbenxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I own it

Thats the thing, I do own the file, i created it, its in a directory of mine, and I can change its permissions - until i tried to change them to whatever i was reading about suid or something, and it said i didnt have permission to do that...lets assume for now I have all permissions to do what i want to the file...why from crontab is the permission denied?

Reply With Quote
  #4  
Old November 22nd, 2004, 02:54 PM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
can the java app write to the file when you run it standalone without crontab? Which user's crontab file did you put the crontab entry into? Was it yours or somebody else's? Remember the cron will run with the permissions of the script owner.


christo

Reply With Quote
  #5  
Old November 22nd, 2004, 03:03 PM
xxbenxx xxbenxx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 8 xxbenxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
yes, the java app can write to the file standalone. And the crontab is my crontab file.

Reply With Quote
  #6  
Old November 22nd, 2004, 03:20 PM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
hmmm - can you post back the result of

$ ls -al file-you-are-writing-to.txt

and

$ ls -al java-binary-in-question.class

and

$ cat /var/spool/cron/crontabs/yourusername


christo

Reply With Quote
  #7  
Old November 22nd, 2004, 03:24 PM
xxbenxx xxbenxx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 8 xxbenxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
-rw-r--r-- 1 porterfi compsci 114 Nov 22 15:41 data.txt

-rwx--x--x 1 porterfi compsci 4998 Nov 22 14:34GetData.class*

cat: /var/spool/cron/crontabs/porterfi: Permission denied

Reply With Quote
  #8  
Old November 22nd, 2004, 04:19 PM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
okay and try this too:

$ ls -al /var/spool/cron/crontabs/*

and

$ crontab -l

and


$whoami

and post the results,

christo

Reply With Quote
  #9  
Old November 22nd, 2004, 05:13 PM
xxbenxx xxbenxx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 8 xxbenxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ls: No match.

* 0 * * 1-7 cd /usr/local/home/porterfi/public_html/Forecast; java GetData

porterfi

Reply With Quote
  #10  
Old November 22nd, 2004, 05:18 PM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
Quote:
Originally Posted by xxbenxx
ls: No match.

* 0 * * 1-7 cd /usr/local/home/porterfi/public_html/Forecast; java GetData

porterfi


does this work if you just do it like this:


* 0 * * 1-7 java /usr/local/home/porterfi/public_html/Forecast/GetData


christo

Reply With Quote
  #11  
Old November 22nd, 2004, 05:32 PM
xxbenxx xxbenxx is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 8 xxbenxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
no, that does not work. I cannot even run java /usr/local/home/porterfi/public_html/Forecast/GetData
from my command line. But i know with the other way, it does work, because the java program outputs to stdout and to the file the same thing, and I get in my 'output email' from crontab the correct output, followed by the error that the i couldnt touch the file cause my permission is denied...

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Crontab and (permission denied)


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


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway