I'm running a java tool as a command line app using cronjob:
java -jar /var/java/-myfile.jar
By default I'm using logback
and write to /var/log/mylogfile.log
.
Problem: the user running the jar has no permissions to write to the /var/log/
folder.
That folder has only permissions to `root syslog'.
Question: should I run the jar as sudo
? Or should I give the running user write permissions to that folder? If yes, how?
No. Far too dangerous since you could then change about anything to the system and a single misplaced space could remove your whole system.
Yes. The 2 main commands are to change write permissions and change the USER of your log file:
where $USER is your current active user and {yourdir}/ is a directory you defined (mysql and apache for instance use their own directory in
/var/log/
instead of filling up/var/log/
). It is a slightly better method.