Running program as user with no shell


Recommended Posts

Hey guys

I have created a user with no shell like this:

useradd -s /sbin/nologin username

for a program that I want to run as this user. I also do not want this user to be able to login - ever.

I am also using a startup script in /etc/init.d/ that starts this program as this user on system boot, and stops it on shutdown.

However, when I try to run the script: service myservice start

I get this error message: This account is currently not available.

I have made sure that the user owns the program

chown username myprogram

The script is attempting to run the program like this: su - username -c /path/to/program

I am definitely not a Linux expert, more of a novice. Any advice on getting this to run properly? Thanks! Oh, and if it matters this is on CentOS 5.

I tried that as well - I still get the: This account is currently not available.

useradd -s /sbin/nologin user

passwd user

password

chown user:user /directory/and/program

service myinitdscript start

the script calls like this:

su - user -c my command

It is trying to execute java to run a jar file. The user has permissions for the jar, does it need permissions for Java as well? Thanks.

I think I finally got it guys. I modified my script to call my Java JAR like this:

su - -s /bin/bash user mycommand

I can execute my command this way. However I am not sure if this is the proper way to do this. The program is running as the intended user. However if I do a ps -ef I can see that the above process is still running as root even though the command and it's associated processes have closed.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.