Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
07-06-2017, 02:23 AM
|
#1
|
Member
Registered: Sep 2015
Posts: 495
Rep:
|
motion script now runs motion without sudo
I was able to figure out the pid file. Simply tell motion to write its pid in my user folder
This script actually works to rename the motion-files folder to one with datetime appended, then creates a new motion-files folder for the motion program to create new jpgs.
It works ok even without killing motion running process.
If I try 'pkill motion', the script terminates at that line.
execute 'pkill motion'in a terminal and it kills motion, just won't work in a script.
How could I kill motion daemon in a script?
Code:
#!/bin/bash
echo "foo"
#pkill motion
mv /home/scott/testmotion/motion-files /home/scott/testmotion/motion-files$(date +%F-%H:%M:%S)
mkdir /home/scott/testmotion/motion-files
motion
echo "foofoo"
datetime descriptors list
https://www.cyberciti.biz/faq/unix-linux-bash-get-time/
Last edited by sdowney717; 07-06-2017 at 05:50 AM.
|
|
|
07-06-2017, 11:41 AM
|
#2
|
LQ Veteran
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: Rocky 9.4
Posts: 5,804
|
What is the name of the script?
From man pkill:
Code:
pkill will send the specified signal (by default SIGTERM) to each process
and
Code:
The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat.
I'm just guessing, of course.
|
|
|
07-06-2017, 12:06 PM
|
#3
|
Member
Registered: Sep 2015
Posts: 495
Original Poster
Rep:
|
Quote:
Originally Posted by scasey
What is the name of the script?
From man pkill:
Code:
pkill will send the specified signal (by default SIGTERM) to each process
and
Code:
The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat.
I'm just guessing, of course.
|
But I cant use pkill in the executable script as it kills the script, Terminal echoes back 'terminated' and wont run the rest of the script.
|
|
|
07-06-2017, 12:10 PM
|
#4
|
LQ Guru
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342
|
Quote:
Originally Posted by sdowney717
But I cant use pkill in the executable script as it kills the script, Terminal echoes back 'terminated' and wont run the rest of the script.
|
go back and take a peek at your other post I left you some goodies
http://www.linuxquestions.org/questi...75#post5731475
|
|
|
07-07-2017, 09:16 AM
|
#5
|
LQ Veteran
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: Rocky 9.4
Posts: 5,804
|
I'll try one more time. What is the name of the script?
|
|
|
07-07-2017, 09:20 AM
|
#6
|
Member
Registered: Sep 2015
Posts: 495
Original Poster
Rep:
|
Quote:
Originally Posted by scasey
I'll try one more time. What is the name of the script?
|
Motionsh.sh I wrote it.
|
|
|
07-07-2017, 09:25 AM
|
#7
|
LQ Veteran
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: Rocky 9.4
Posts: 5,804
|
Quote:
Originally Posted by sdowney717
Motionsh.sh I wrote it.
|
So, if pkill kills all jobs that match the pattern given as seen in the output of /proc/pid/stat it's just possible that it's killing your
script because of the name.
Try calling it some name that does not include the word "motion," uncomment the pkill line and see if it will run.
Let us know what happens, please.
|
|
|
07-07-2017, 09:28 AM
|
#8
|
Member
Registered: Sep 2015
Posts: 495
Original Poster
Rep:
|
Ok will do this today.
|
|
|
07-07-2017, 05:25 PM
|
#9
|
Member
Registered: Sep 2015
Posts: 495
Original Poster
Rep:
|
Yes, it must have been killing the script due to its name.
I renamed script to mmm.sh, and it runs fine
the script
Code:
#!/bin/bash
echo "foo"
pkill motion
mv /home/scott/testmotion/motion-files /home/scott/testmotion/motion-files$(date +%F-%H:%M:%S)
mkdir /home/scott/testmotion/motion-files
motion
echo "foofoo"
the terminal
Code:
scott@scott-P5QC:~/Desktop$ ./mmm.sh
foo
[17686912] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
[17686912] [NTC] [ALL] motion_startup: Motion 3.2.12+git20140228 Started with SDL support
[17686912] [NTC] [ALL] motion_startup: Logging to file (/home/scott/testmotion/motion.log)
foofoo
scott@scott-P5QC:~/Desktop$ ./mmm.sh
foo
[27541888] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
[27541888] [NTC] [ALL] motion_startup: Motion 3.2.12+git20140228 Started with SDL support
[27541888] [NTC] [ALL] motion_startup: Logging to file (/home/scott/testmotion/motion.log)
foofoo
scott@scott-P5QC:~/Desktop$ ./mmm.sh
foo
[9867648] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
[9867648] [NTC] [ALL] motion_startup: Motion 3.2.12+git20140228 Started with SDL support
[9867648] [NTC] [ALL] motion_startup: Logging to file (/home/scott/testmotion/motion.log)
foofoo
scott@scott-P5QC:~/Desktop$
|
|
|
07-07-2017, 06:11 PM
|
#10
|
LQ Veteran
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: Rocky 9.4
Posts: 5,804
|
Quote:
Originally Posted by sdowney717
Yes, it must have been killing the script due to its name.
I renamed script to mmm.sh, and it runs fine
|
Cool! Glad we found the solution.
|
|
|
All times are GMT -5. The time now is 03:03 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|