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 04-17-2012, 06:49 PM   #1
lonesoac0
Member
 
Registered: Jan 2010
Distribution: Ubuntu
Posts: 88

Rep: Reputation: 4
Application Rotation


Hello all,

I created a bourne shell script that lets me launch feh and firefox without first having a X session. I am running this script with the help of the crontab program. The sytax that I use for launching my script is:
Code:
*/8 * * * * $HOME/feh_and_firefox &
The issue that I am having is that the script feh_and_firefox, occasionally does not write to my .number file. As a result my .number file does not have a value at all. I do not know what could be causing this problem.

Please advise.
Attached Files
File Type: txt feh_and_firefox.txt (781 Bytes, 2 views)
File Type: txt launching_FF.txt (136 Bytes, 2 views)
 
Old 04-17-2012, 07:19 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
I'd start by adding a default clause at the bottom so that if no previous numbers are matched, it writes some useful info to .number.

Also, add
Code:
set -xv
just after the #!/bin/sh line and redirect/capture all output in a log file.

Any reason for using sh instead of bash?

Last edited by chrism01; 04-18-2012 at 12:49 AM.
 
1 members found this post helpful.
Old 04-17-2012, 07:37 PM   #3
lonesoac0
Member
 
Registered: Jan 2010
Distribution: Ubuntu
Posts: 88

Original Poster
Rep: Reputation: 4
I did have something at the bottom of the script to do what you suggested but I thought that I was doing something wrong. I had something like:
Code:
if [ "$blah" -eq "" ]
 then
  echo "1" > $HOME/.number
fi
The reason that I removed that simple clause was that I thought that I was doing something wrong with my original scripting. In theory, I should not have to write the additional code since my original code goes into a loop.

As for the
Code:
set -xv
Just to be sure, you want me to add it like:
line 1: #!/bin/sh
line 2: set -xv

Finally, I use bourne shell for the portability of the scripts that run on it. It is true that Bash is the defacto shell, but for my previous stated reason and personal preference. If you can think of a better Bash script then I am alllll ears! Thank you for your response.
 
Old 04-18-2012, 12:52 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
Re set cmd: yep, just like that

Re default; don't use an if, just record what the param was and the current value in .number; in fact the entire content of .number, and put it in a separate logfile.
(along with the set -xv output).

Can I also recommend [[ ]] http://tldp.org/LDP/abs/html/testcon...ml#DBLBRACKETS
 
  


Reply

Tags
bourne, crontab


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
Log rotation for my application logs parteekM Solaris / OpenSolaris 10 02-06-2012 12:55 PM
Log rotation for my application logs parteekM Solaris / OpenSolaris 5 02-04-2012 04:25 AM
Monitor rotation mdkusr Linux - Hardware 1 01-12-2006 01:57 PM
Metalog Rotation Crashed_Again Linux - Software 0 02-09-2005 02:31 PM


All times are GMT -5. The time now is 08:54 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration