I Can Start LFTP At X Tme - But Can I Kill Process At X Time

Hiya,

I normally read until I find an answer but I am stuck so here goes:

I have unlimited satellite broadband between 00:00 and 06:00am, out of that time I have to be careful so backing up my site needs to happen then - I would like to learn how to do it on the command line.

Here' where I am at:

lftp [my bookmark]

[set local directory]
at:2359
mirror --use-pget-n=5 [remote folder]

I am using a low tech electic timer as a killswitch on my router -
is a command line 'kill switch' possible:

at 0600 kill all ?

Yesterday I though I ended the proces but I had not - must have been a typo - and it carried on and on and on.

I would like to automate it into a script to run periodically eventually - but that is another job.

Thanks


Similar Content



Kill Zombie Process Via C Program Without Killing Main Process

Hi ,
In my program, for a process A executing operation, there are multiple threads created.
One of the thread A checks whether process is active or not
Second thread B executes a function
One of the periodic thread C calls a callback function that executes an audit after every 30 secs.

In the audit , the function uses g_spawn_commmand_line_sync() function to spawn a child process that executes a command line (shell script).

Since g_spawn_commmand_line_sync() spawns a new child process .
In the error case scenario, the spawned child process got stuck and became zombie process. It did not get killed.Also it acquired sockets which were assigned to a thread B executing operation.

Even though the thread B got terminated ,the child process did not release the sockets that were connected to it.


My question is ,I have to automate this in C program that if it finds spawned process of g_spawn_commmand_line_sync() defunct, the
health check thread B should be able to clean it without klling the main process.

i could not find any spawn function that will help me find the PID of g_spawn_commmand_line_sync() spawned process.

I get the details from ps commands. But how can I find it in a c-program?

Kill -3 Pid > /tmp/process.txt Not Working?

Hi All,
I am trying to get a dump of a process using kill and it doesn't look to be working, can someone explain what I am doing wrong?

Code:
systemctl start snmpd.service

Code:
pgrep snmpd
4233

Code:
kill -3 4233 > /tmp/snmp_pid.txt

OR

Code:
kill -SIGQUIT 4233 > /tmp/snmp_pid.txt

Yes the process quit's which is fine but there is no output from the process in /tmp/snmp_pid.txt.

Can someone please explain?

Thanks

Bash Shell Scripting Need Help Figuring Out Process For Homework - JUST WANT DIRECTIO

Ok yes this is a homework assignment BUT I am NOT looking to have the answers given to me. I am in the 6th week of my first Linux class ever and we are in our few weeks of beginning scripting. I have some ideas of what to do or where to start but not many and no one to bounce any ideas off...we are using UNIX Bash shell so any others I have no clue. The scenario is that I need a script that searches all my users home directories for bad words. I need the script to report to the screen certain info like username and word found and path. It should ask a user if it is good or bad and if bad be put into a file of list of bad file names, if good remove from list and no longer flagged by the script. What I have so far is wanting to somehow do a loop. I do know that if I do a grep -r -e kill -e steal /home/* I get a list of what I need. I also know that the list is separated by delimiters which I can pipe to get a variable for the things I need. I also know that I can put it to a file with a > filename.txt

What I have no clue is how to start a loop that would do this...

for each line in filename.txt
UNAME=...
LOC=...
TXT=...
echo "Username: $UNAME, Line with bad word found: $TXT, and Path and file name: $LOC. Is this a BAD file? (Y)"
Read YORN

if ["$YORN" = "Y" ]; then
>> (line of text from grep) badfiles.txt
fi

Next or whatever goes there...sorry if this is crazy I just really need some direction. I am trying to learn so please don't give me the answer...that will do nothing for me and I will not be able to explain the code I came up with.

Best Way To Run Two Interdependent Scripts

Hi All,

I have two scripts, the aim of these two scripts is, to check whether a particular script is running or not, if it wont runs, then throw a mail.

How i Achieved this output is, I wrote first script.

I created an infinite while loop which performs below steps

1. It creates a touch file
2. Triggers the script which needs to be monitored if its working or not.
3. Removes the touch file.

If the second step fails, then the remove file command will not happen and the script will stuck there itself.

I created an another script which checks the creation time of the touch file and if it is more than ten minutes, it means the second step in the first script is hanged, which also means that particular script is not working.

So if the creation time is more than 2 minutes the second script will throw a mail.

Below are the two scripts.

Code:
#!/bin/ksh



userid="chansd"

filename="/apps/log/check.txt"

while true ;do
touch $filename
pass=`/apps/eDMZ/call_st.ksh $userid`
sleep 20
rm $filename
done

Below script checks the file creation time and throws email if it is older than 2 minutes
Code:
#!/bin/ksh


filename="/apps/log/check.txt"

if [ -f "${filename}" ]
then
if test "`find $filename -mmin +2`"
then
echo "script is not working ! Please act on it" | mail -s "Script  is not working" Example@mail.com
fi


else

        exit 1

fi


What im going to do is

1. I am going to run the first script in background so it runs forever.
2. I am going to run the second script in cron forevry 5 mins to check the file creation time.

3. So if the first script hangs . I will kill the process using process id and after the issue resolves with the inner script, I will run the main script again.

I am new to Linux, Please let me know if this approach will work as expected.

OpenSuSE 12.3 Auto Mount USB

Hi
First post, hope this is in the right forum.

When I plug a USB key into my PC it appears in dolphin but isn't mounted until I click on it.

Running df at the command line doesn't show the USB key until I've clicked it in dolphin then I can access it via the command line.

I'm trying to find a way to automatically mount the key when I boot up.

I found a script that scans /dev/disk/by-label and mounts any disks it finds in to the correct location. This works great from the command line.

I tried adding it to /etc/init.d/boot.local but on a reboot it failed as the USB disk hadn't been detected when boot.local ran.

So where do I need to put this script so it will run when the machine has booted and the USB key has been detected by the OS?

The PC is unattended so I need to be sure that if its remotely rebooted the script is run so the key is mounted.

Thanks

How To Kill UDPv4 Connections On Googlephone With Rudimentary Linux Shell?

hello everyone
I use Googlephone MTS 970 which runs under android 4.1.1 and has installed only rudimentary Linux, I've run 3c network manager and find out that there were established at about 7connections of UDPv4. I think they were VoIP connections established by some local fun lovers (I'm living in a hostel).
so, am I right and how can I kill such connections?

Scripts To Respond To Prompts

I have searched and was unsuccessful in finding a quick command or example to use.

I'm looking to automate an update process using command line in Debian.
Normally I'd use apt-get update|upgrade|dist-upgrade .

If apt-get finds a package to update it queries a Y/n response.
My objective is to have a script determine if this prompt is there, and if so to respond with 'Y'.
If not then it should not enter a response.

I know I'll need to use an IF/ELSE function, but what I'm having difficulties locating is to read the output of apt-get .

I know there's books and sites available, but they are all long and sometimes difficult to read or understand. And maybe my keywords are the right ones to use, as I'm not able to pinpoint a solution.

Thanks for your assistance.

Linux Pro's And Noobs! A Challenge, Please Take A Crack At This! (TIME SENSATIVE,)

Do it like this is your situation, your server, and the dir that are mentioned below, act like they are yours! im just looking for an accurate answer!
(student of O'Rielly School of Tech)


whenever you log in, your shell executes commands that it finds in your dotfiles, specifically .bash_login. In your .bash_login, add a series of commands that will first create a directory named ~/sysadmin1/my_peeps/$DATE, where $DATE is today's date in the format mmddyy. This command should succeed whether or not the directory ~/sysadmin1/my_peeps already exists. Then, it will redirect the output of the w command (which lists the currently logged in users on the system) to a file inside this newly created directory called users.$TIME, where $TIME is the current time in the format hhmmss (use 24 hour time).

In order to do this, you must use a new concept: assignment of a variable from the output of a command. For example, in order to set the variable EXAMPLEDATE using the unformatted output of the date command, you would do the following:

EXAMPLEDATE=`date`

The characters surrounding the date command are called "backticks." They are usually located on the same key as ~. They are not single quotation marks. This is actually another kind of expansion called "Command Substitution" (you can learn more in bash's manpage).

For this project, you can use the date command to get both the date and the current time, however, you will have to consult date's manpage to find out how to change the formatting.

Awk On Remote Server

Hi,

I am running awk command on remote server it is not giving desired results but if i run the same command on local server. it works as expected. Can anybody help me to resolve this and let me know the logic behind this?

Remote server

# ssh test 'free -g | grep Mem | awk -F " " '{ print $2 }''
awk: cmd. line:1: {
awk: cmd. line:1: ^ unexpected newline or end of string

local server
# free -g | grep Mem | awk -F " " '{ print $2 }'
31


Thanks in advance.

Backing Up With Dd

hi guys,

i want to back up my centos server that has a few virtual machines on it...i read that some people were saying dd is a very good way to do this. but a lot of people dont cause of fear of the command line.

i would like to write a script that backus up the entire hard drive to a ext usb hard drive.

i have a couple of questions though.

1) am i better off using a cloning software like acronis or storage craft.

2) can dd also restore a system to a bootable state or is it really just a backup.

3) can you still use the system while it is backing up?

thanks...