LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 07-06-2017, 02:23 AM   #1
sdowney717
Member
 
Registered: Sep 2015
Posts: 495

Rep: Reputation: Disabled
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.
 
Old 07-06-2017, 11:41 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 5,435

Rep: Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056
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.
 
Old 07-06-2017, 12:06 PM   #3
sdowney717
Member
 
Registered: Sep 2015
Posts: 495

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
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.
 
Old 07-06-2017, 12:10 PM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
Quote:
Originally Posted by sdowney717 View Post
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
 
Old 07-07-2017, 09:16 AM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 5,435

Rep: Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056
I'll try one more time. What is the name of the script?
 
Old 07-07-2017, 09:20 AM   #6
sdowney717
Member
 
Registered: Sep 2015
Posts: 495

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
I'll try one more time. What is the name of the script?
Motionsh.sh I wrote it.
 
Old 07-07-2017, 09:25 AM   #7
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 5,435

Rep: Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056
Quote:
Originally Posted by sdowney717 View Post
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.
 
Old 07-07-2017, 09:28 AM   #8
sdowney717
Member
 
Registered: Sep 2015
Posts: 495

Original Poster
Rep: Reputation: Disabled
Ok will do this today.
 
Old 07-07-2017, 05:25 PM   #9
sdowney717
Member
 
Registered: Sep 2015
Posts: 495

Original Poster
Rep: Reputation: Disabled
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$
 
Old 07-07-2017, 06:11 PM   #10
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 5,435

Rep: Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056Reputation: 2056
Quote:
Originally Posted by sdowney717 View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] I plug in webcam and it is at video1 but 'motion' runs on video0 sdowney717 Linux - Newbie 1 07-05-2017 04:55 PM
LXer: Cities In Motion & Cities In Motion 2 Released For Linux On Steam LXer Syndicated Linux News 0 01-09-2014 08:32 PM
Motion help please (Motion only supports mmap) ?? RaeMarvin Linux - Software 4 09-06-2012 12:25 PM
Error with "SDL_MouseMotionEvent *motion = event->motion;" aatwell Programming 3 11-30-2007 01:46 PM
Suse 9.2 runs in slow motion BillRandolph Linux - Laptop and Netbook 15 12-28-2004 03:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration