Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion crontab & gnome-schedule do not run bash script
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bit Twister  
View profile  
 More options Sep 9 2012, 1:18 am
Newsgroups: comp.unix.shell
From: Bit Twister <BitTwis...@mouse-potato.com>
Date: Sun, 9 Sep 2012 05:18:02 +0000 (UTC)
Local: Sun, Sep 9 2012 1:18 am
Subject: Re: crontab & gnome-schedule do not run bash script

On Sat, 8 Sep 2012 17:55:16 -0700 (PDT), Rajib Bandopadhyay wrote:

First, you may want to consider setting your Usenet application to
word wrap at about 60 characters to fall withing Usenet guidelines.

That extra space gets used for the reply depth indicators.

Some subject matter experts may not bother to reply to your post/problem
if they have to re-format it.  :-(

> Friends, things are pretty quickly getting off my zone of
> comprehension.

Do not worry, you are being fed information piecemeal about little
things that can bite you when running in cron and some information
about what certain types of apps require as part of the basic setup.

> Maybe a few months from now I would be in a position
> to comprehend your discussion,

Heh, heh, but by then it will seem like you know even less.  :)

> but presently, I am a newbie.

Well, doing a  "locate bin/ | wc -l" on my Mageia Linux shows 5072 applications.
Rest assured I am pretty much a newbie also.  :-D

>  So
> what should be my script, considering that I use Debian Squeeze
> 6.0.3 main contrib non-free repos?  

If you were to read http://www.catb.org/~esr/faqs/smart-questions.html ;
providing distribution and release enables subject matter experts to
provide more precise information/instructions. Depending on the
question, would not hurt to provide your Desktop manager name (Gnome,
KDE, LXDE, XFCE, Openbox, Enlightenment, Fvwm, Fluxbox, Window Maker,
IceWM, Blackbox, Afterstep, .....) and if you are running a 32 bit or
64 bit install.

As an example, you can compare what your interactive environment
contains with what your cron environment has. Put
    env | sort > cron.env
in a cron script. Now run the command
   env | sort > term.env
in a terminal. Once the cron job completes you can do a
    diff -bBw cron.env term.env
to see what is different.

Lots of the stuff in term.env may not be required, but that will
depend on what application(s) you execute in the cron job/script.

You may want to place environment variables in a script and source it.
That allows you to have one place to make changes which all cron jobs
can use.

Example. I have a several scripts that I source to make my script
writing much easier. They reside in separate partition called
/local/bin.  See:

$ cd /local/bin
$ ls -1 fun*
function_path_app
functions_change
functions_date
functions_flag_email
functions_install
functions_systemctl
function_stopwatch

My basic cron script would start out like:

#!/bin/bash
. /local/bin/function_path_app

That function has the basic PATH and any other variables I consider
necessary as a generic setup.

$ sort /local/bin/function_path_app | uniq | wc -l
23
shows that I have 23 lines of code. It is up to you what goes in your
setup scripts.

What I want to show you is my PATH setting in function_path_app
    export PATH="\
    /sbin:/usr/sbin:/usr/local/bin\
    :/local/bin:/bin:/usr/bin:/usr/bin/X11\
    :/usr/games:/usr/lib64/qt4/bin\
    :$HOME/local/bin\
    "

What is of intrest is   /usr/lib64/qt4/bin

In particular is /lib64/. That is required on 64 bit installs. On 32
bit installs it would be /usr/lib/qt4/bin

How did I figure out what I needed there? you ask. It was easy. I did
a "echo $PATH" in a terminal and added it to function_path_app

Some java applications might want JAVA_HOME and CLASSPATH set.

Just for fun run this in a terminal.

   env | sort | grep PATH

I do not have a Debian install handy so I can not tell you what to
ignore.

Add my
   if [ -z "$DISPLAY" ] ; then
     export DISPLAY=:0
   fi

and those path variables you saw in tha above sort to your script.
Test/run your script in the terminal to prove it works, then run
the script in cron.

You may want to bookmark this url
http://tldp.org/LDP/abs/html/index.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.