Code Geas Coder
Code Geas Coder

Reputation: 1989

find a way to make a command not possible to execute

I have a user in linux

and i have a problem, because the user in linux is accessed by many users and in some times somebody for error write crontab -r and delete all crontabs.

Is there a way to lock the command: "crontab -r"? (i am not the user root, only have this permisions in this user)

But i need that all the persons in the user can create crontab ("crontab -e") or list the crontab ("crontab -l")

I have a red hat server.

Thanks

Upvotes: 1

Views: 52

Answers (2)

tripleee
tripleee

Reputation: 189648

If all you need to prevent is carelessness, a simple wrapper in /usr/local/bin/crontab is all it takes.

#!/bin/sh
case $1 in
 -r) echo "$0 -r disabled; aborting" >&2
     exit 1;;
esac
exec /usr/bin/crontab "$@"

Upvotes: 2

Joe Sewell
Joe Sewell

Reputation: 306

You'd have to make crontab into a shell script that would catch this and throw an error. How you would tell when the operation is proper or not, though, is up to you. Since many different people log in with the same username, there's no intrinsic way to tell when it's proper to do something and when it's not.

Upvotes: 1

Related Questions