Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
this is pretty simple the problem is that you will need to learn scripting bash style.
you need to set 2 conditions one being time and two being transfer info then have it execute the shutdown script. the first thing I would want to do is determine if proftp is running. I do not use proftp so I have no idea. but in theory you could set proftp to shutdown after download or up load. then write something like
#/bin/sh
#script to shutdown after 2:30 am after proftp stops
ps -A|grep proftp>/var/tmp/tmp.data
if [ -f /var/tmp/tmp.data && `date +%H%M ` = 230 ] ; then
rm -rf /var/tmp/tmp.data
shutdown -h now
else
#<<<<insert what you want it to do if not>>>>>
fi
this should do it. this makes the basic assumption though that proftp will shutdown after it is running and that the ps -A command will show it as proftp
ok bye bye now
Thanks for reply.
The problem is I want to allow person to access my proftpd, if there is traffic (active u/l or d/l) ... it will continue after 02:30 am ....
but if 02:30 , there is no active traffic (proftfd is running), shuwdown system.
1) My proftpd allow people u/l or d/l data, I want to make the linux box
shutdown if it detect nobody active for proftpd at 02:30 am
(I presume they sleep) and my script test to make shutdown command
2) if people are still active at 02:30 in proftpd, the shutdown is not performed
3) this script may be scheduled to run at every 30 or 60 minutes....etc
Thanks for any more hint because I can see xferlog log down the proftpd activity but I do not know how to test when people is doing u/l or d/l ?
#! /bin/bash
#
# To check if there is any active ftp user by "ftpwho"
# if nobody, issue "shutdown -h now" to shutdown system
# using a temp file "/etc/ftpwho.txt"
#
/usr/local/bin/ftpwho > /etc/ftpwho.txt
NOUSER="no users connected"
NOONE=`grep -i "$NOUSER" /etc/ftpwho.txt`
#
if [ -z "$NOONE" ] ; then
exit 0
else
echo >> /etc/ftpwho.txt
echo "##### System shutdown on `date` by `whoami`" >> /etc/ftpwho.txt
/sbin/shutdown -h now
fi
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.