Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-27-2014, 11:48 PM   #1
Registered: Mar 2012
Posts: 42

Rep: Reputation: Disabled
Question Crontab strats 2 processes, calling 1 script

My crontab had the command:
50 08 * * 1-5 /home/ /home/arguments 2> /dev/null

59 23 * * 1-5 killall
Which worked perfectly fine, but when I used to do
ps aux | grep SCRIPT
it showed

myuser 13898 0.0 0.0 4444 648 ? Ss 08:50 0:00 /bin/sh -c /home/ /home/arguments 2> /dev/null

myuser 13900 0.0 0.0 25268 7384 ? S 08:50 0:00 /usr/bin/python /home/ /home/arguments
  1. Why are 2 processes been shown
And the killall command also used to work fine.

I made a change to my script and in order to get the new behaviour, I had to kill the currently running scripts and I used
kill 13898 13900
After that I used the same command (as in crontab)
/home/ /home/arguments 2> /dev/null
  1. But now after restrating the script, it showed only 1 process (which makes sense)

Everything looks good till here, but this time the killall MY_SCRIPT in the cronjob didnt work, it said could not find pid. And the script kept on running until I had to manually kill it.

Need to find out the reason for this behaviour:
  1. Why 2 processes from cronjob
  2. Is there something wrong the way I restrated the script
  3. How do I make sure that next time I restart the script, the cron should kill it for sure
Old 07-28-2014, 08:55 AM   #2
Senior Member
Registered: Aug 2009
Distribution: CentOS
Posts: 3,514

Rep: Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545Reputation: 1545
The cron daemon needs to invoke a shell to process the "2>/dev/null" redirection. The only way I can think of to get rid of that shell process is to change to a shell script that explicitly exec-s the python interpreter:
exec python - "$@" <<EOF
I think that will work, but I don't have a suitable script for testing it.


cronjob, crontab, kill

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
calling a shell script present on another server using perl script. anandg111 Linux - Server 4 07-18-2012 12:23 AM
Calling Crontab over non interactive ssh session IgnitusBoyone Linux - General 5 06-09-2011 04:22 AM
Calling perl script and passing variable from php script hosea Programming 5 10-21-2008 08:01 AM
how to pass a variable from a called script back to the calling script steven.c.banks Linux - General 2 05-05-2008 02:00 PM
suspend running processes with crontab merlin23 Linux - Newbie 1 12-07-2004 03:09 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:35 PM.

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