LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-17-2016, 03:11 AM   #1
n1uro
Member
 
Registered: Feb 2016
Posts: 31

Rep: Reputation: Disabled
cron and a dosemu session


I'm running a hamradio system under DOSEmu and have been trying to get cron to restart it if it crashes. I've written a shell script that works PERFECT if I run it manually, however if cron attempts to execute it, somehow it fails to restart the process.

My cron line is:
*/5 * * * * root /usr/local/bin/noscheck

My noscheck script is:
#! /bin/sh

GOOD=`fping nos.n1uro.ampr.org |awk '{print $3}' `
PID=`ps ax|grep dos|grep nos|awk '{ print $1}' `
if [ -z $PID ]; then
echo "MFNOS is $GOOD, resetting..."
su -c /home/n1uro/n n1uro &
sleep 30
fping nos
exit 0
fi
if [ $GOOD != alive ]; then
echo "MFNOS is $GOOD, resetting..."
PID=`ps ax|grep dos|grep nos|awk '{print $1}' `
kill -9 $PID
su -c /home/n1uro/n n1uro &
sleep 30
fping nos
exit 0
fi
echo "MFNOS is $GOOD"
exit 0
fi
exit 0

and finally the 'n' script is:
#!/bin/sh
cd /path/to/n
sudo ip route add x.x.x.x via y.y.y.y dev sl0 table 1
setuid user sudo nice -19 dosemu -f /etc/dosemu/nos.conf -d -n
exit 0


Sometimes the program simply hangs and dosemu doesn't exit (note: I'm running 2 concurrent DOSEmu sessions so capturing the right pid is important). Again if I run it manually it's perfect and the session reloads. Via cron however, it fails... any ideas? I'm pretty stumped on this one.

Last edited by n1uro; 03-17-2016 at 04:29 AM.
 
Old 03-21-2016, 10:15 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,605

Rep: Reputation: 4361Reputation: 4361Reputation: 4361Reputation: 4361Reputation: 4361Reputation: 4361Reputation: 4361Reputation: 4361Reputation: 4361Reputation: 4361Reputation: 4361
cron has its own environment, therefore probably your commands are simply not found. You need to set PATH or use full path.
also insert set -xv at the beginning of the script to see what's happening and redirect stdout and stderr into files.
 
1 members found this post helpful.
Old 03-21-2016, 01:34 PM   #3
n1uro
Member
 
Registered: Feb 2016
Posts: 31

Original Poster
Rep: Reputation: Disabled
Actually the whole process is quite deep and requires an actual user to execute it.
I was able to trace the processes of each script days ago and realized that this
as it is will be impossible. I'll need to research another way.
 
Old 03-21-2016, 02:44 PM   #4
n1uro
Member
 
Registered: Feb 2016
Posts: 31

Original Poster
Rep: Reputation: Disabled
Because of the nature of the sequence of tasks, it's impossible to reach the goal of this being a working cronjob.
 
Old 03-21-2016, 02:45 PM   #5
n1uro
Member
 
Registered: Feb 2016
Posts: 31

Original Poster
Rep: Reputation: Disabled
Marking as resoloved just to close this thread.
 
  


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
Session key renegotiation if session lasts longer than configured (e.g. an hour) then session keys needs to be renegotiated. dakshinya Linux - Newbie 1 02-04-2016 05:15 PM
cron:session flood my auth.log guarapo Debian 3 12-03-2010 02:47 PM
What the %$#@ is pam_unix (cron:session) doing every ten minutes? (/var/log/auth.log) CoffeeKing!!! Linux - Security 3 02-05-2009 08:07 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 02:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:02 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration