Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

Getting permission denied on linux running a script

Hi,
on running a command  (here yatra is script containing commands )
daemon --user=yatra /opt/yatra/yatra
/opt/yatra/yatra: line 7: /var/run/yatra.pid: Permission denied
/opt/yatra/yatra: line 6: /var/log/yatra/startup.log: Permission denied

whereas i have already executed the following commands to give appropriate conditions :
chown -R yatra:yatra /var/log/yatra
[root@localhost log]# chmod ug+x /opt/yatra/yatra
[root@localhost log]# chown -R yatra:yatra /opt/yatra/


I have created a user and group with same name yatra

Here are the permission also :
-rwxr-xr-x. 1 yatra yatra 151 May  5 00:50 /var/log/yatra/startup.log
-rwxr-xr-x. 1 root root 6 May  5 00:50 /var/run/yatra.pid

Here is my yatra script :
#!/bin/bash


java="/usr/java/default/bin/java"

jar="/opt/yatra/yatra.jar"

serviceLogFile="/var/log/yatra/startup.log"   
       # log file for StdOut/StdErr

$java -DCONFIG=/etc/yatra -jar $jar >>$serviceLogFile 2>&1 &

echo $!>/var/run/yatra.pid


Open in new window



what could be the reason for this permission error ?
Thanks
ASKER CERTIFIED SOLUTION
Avatar of tel2
tel2
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the points, Rohit!

What was the cause and solution to this error?:
  "opt/yatra/yatra: line 6: /var/log/yatra/startup.log: Permission denied"
Avatar of Rohit Bajaj

ASKER

hi
actually there was some setup issue on my virtual box machine....for some unknown reason the problem automatically got resolved when i tried deploying rpm..