SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I can start programs on boot by putting commands in rc.local. My question is, how do start programs on boot under a different user other than root?
My second question is ... where can I get info on making a script that I can use in cron. I want it to check if a program is running, and if not ... run a program.
Longer answer read "man su" and also read "man chmod" and more specifically for "X" set user ID for execution.
For cron look in the /etc/cron.* directories, there might be a sample there. If not I am sure someone here could provide an example. Basically you could grep for the process and if it was not found start it.
i added a couple lines so that it will log whenever it confirms the process is running, and whenever it starts another process...
Code:
#!/bin/sh
if /usr/bin/ps aux | grep example.bin | grep -qv grep; then
/usr/bin/date >> /var/log/checker.log
echo "example.bin CONFIRMED" >> /var/log/checker.log
exit
else /usr/bin/example.bin
/usr/bin/date >> /var/log/checker.log
echo "example.bin INITIATED" >> /var/log/checker.log
fi
how can i log the date on the same line as "example.bin CONFIRMED/INITIATED"??
with the script above the log looks like this:
Code:
Sat Jul 31 15:59:49 EST 2004
example.bin INITIATED
Sat Jul 31 16:00:49 EST 2004
example.bin CONFIRMED
Sat Jul 31 16:01:49 EST 2004
example.bin CONFIRMED
That depends of the environment try put echo $PATH >> /var/log/checker.log you will see if /usr/bin is into it, no needs to indicate /usr/bin/date, just date will do
In Linux ps -e might not make a difference, I didn't check. On Irix it does though. Since I bounce around a lot (Irix, AIX, QSH, and BSD, but predominently Linux) I tend to use commands that work relatively consistently across platforms. Thus the -e.
Originally posted by Mephisto In Linux ps -e might not make a difference, I didn't check. On Irix it does though. Since I bounce around a lot (Irix, AIX, QSH, and BSD, but predominently Linux) I tend to use commands that work relatively consistently across platforms. Thus the -e.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.