Programming :: Loading Environment Into Bash Script Called By Cron?

Mar 18, 2010

Script programming question for the experts. I have written a bash script that works fine if I execute from the shell interactively. However, once I schedule it to be executed via cron, it just wouldn't work. I believe this has to do with cron running in a different environment than the one I am in when I putty in.

The bash shell script does refer to environment variables in the .cshrc file. I guess these aren't available to the cron? How can I load them into the script if I want them to be available to the cron locally within the script?

View 1 Replies


ADVERTISEMENT

Programming :: BASH Add Cron Job To Run Hourly

Mar 25, 2010

I have an rsync script I wrote that I have tested and it works perfectly when I run it manually. Now I am working on a server setup script and I have gotten my setup script to create the rsync script in /etc/cron.hourly and restart crond. To spite the fact that the script is in /etc/cron.hourly and I have restarted crond, the script does not run. With that said, how can I script adding the rsync script to run hourly as a cron job?

View 9 Replies View Related

Programming :: Destructor Called On Objects In Deque Without It Being Called Explicitly

Jul 13, 2011

I feel there's a bit of a misunderstanding going on between C++ and me...My problem is that I have a deque of pointers to a class, and create objects then add them to the deque in a for loop. However, the destructor is called on the object as soon as the loop quits.

Code:

This prints:

Code:

Now, if I change the deque from deque<Test*> to deque<Test> then it works fine - I get:

Code:

However, I can't do this with my actual code, because I am creating a deque of pointers to an abstract class, so it won't let me instantiate the class. (This is all so that I can take advantage of polymorphism, and call functions on a set of similar objects without worrying what type of object I'm dealing with).

So, I suppose my question is: what is the correct way to create that deque of pointers to the abstract class? I don't seem to be barking up the right tree currently.

View 4 Replies View Related

Programming :: Bash Script Can't Handle Errors When Run By Cron

Jan 8, 2009

I have a script that that is supposed to send me an e-mail when a host is not responding to ping:

The script works fine when I execute it directly but when cron executes it, the ping error is never picked up by the script so the if statement is ignored.

View 4 Replies View Related

Server :: Script Works When Run But Not When Called By Cron

Aug 28, 2010

I've made a bash script to do scp a file from another server and tested it successfully by executing it manually. However, when I scheduled it by cron, I received a mail from root saying permission denied.

The script is at:

It's supposed to secure copy a file from a remote host to:

The script's content is (No need to supply password as I've done the ssh-keygen thing):

Code:

From what I can make out of the mail, it appears that it has problem saving it to the /home/backup directory.

View 7 Replies View Related

General :: What Is It Called When You Move A PDF Window While It Is Loading

May 18, 2010

1. What is it called when you move a PDF window while it is loading and the window manager does not keep up with the image, (it gets all blurry when the window is moved?)Why does this happen?

2. Why is it that when a browser window is clicked to load a new address it won't always go to it. It has to be clicked again.

3 Why is it that sometimes IE is the only browser that will work on XP. FireFox and Opera will not load a page but IE will.

4 Why is it that Firefox on Linux sometimes everything inside the window is slow to appear. It has to be closed to fix it. When the contents does appear it is all at once.

5.Why is printing different things on Linux a problem. I have a lot of inconsistency with trying to print things from Evince. Some docs print and some won't. Copying and pasting is also a problem for Evince.Why?

6. Is there a way to have Linux Shut down after computer activity has stopped and not just with a timer. Lets say I'm trying to download something and I want it to turn off after it has finished with the down load.

7. Why are some Web pages biased towards Windows. I notice that some java scripts will only run right on Windows machines with IE. A lot of on-line forms are like this.

8. Can (MOVIES, PICTURES AND MUSIC) torrents be downloaded on Linux without risk?

9. It seams that Linux browsers do not keep previous web pages in memory so if you want to go back Linux always has to reload them from the server. Why is this?

10. Why is it that browsers sometimes won't indicate that the page has finished loading, "ever".

11. Why does Linux turn on the number-lock when loading its self?

12. Why can't the brightness be adjusted in Totem? There is a menu to change it but it does not work.

View 1 Replies View Related

General :: How Can Interactive Login Environment Be Duplicated In Cron

May 24, 2010

My execution environment is Linux steamboy 2.6.31-21-generic-pae #59-Ubuntu SMP.If I log in and run a program, the program works properly. The program is a shell script, which executes an environment file, so that path and library settings point correctly.If I have cron run the same program as the same user who logged in, one of the libraries cannot be found. I have sourced .bashrc and the same environment setting file, even though .bashrc executes the same environment file . /home/amr/bin/informix_env.sh

View 1 Replies View Related

General :: Difference Between Cron And Command Line Environment?

Feb 18, 2010

so i have a few shell scripts that execute wonderfully when i type them at the command line but they fail when they are run from cron.

for example, if i run a script from command line that contains

Code:
shopt -s nullglob

to prevent problems with for f in *.mp4 type loops, it works fine from terminal command line but when called from cron, it gives an error->

Code:
/home/centralsqwall/Videos/videochecker.sh: 91: shopt: not found

a couple other random errors as well...

so there is some difference in the shell from cron and the terminal?

i'm running ubuntu 9.10, #!/bin/bash

what are the commands i should be using to echo my environment or simulate cron environment from the terminal?

View 3 Replies View Related

Ubuntu Servers :: Prevent A BASH Script From Being Called To Run Again Until It Exits

Sep 1, 2011

I'm planning on writing a BASH script for my website's server that will process data from user input via HTML forms, and then write data to the website's HTML documents. My question regards how to deal with the possibility that two users send form information very close to the same time, thus having the BASH script being called again while the first instance of the script has not yet finished.

I don't even know what happens in general when a BASH script is called while it is still running. Even if that is ok, and a new, separate script process is started (or whatever really happens), how am I supposed to prevent issues that could come from two different instances of the script trying to write to the same file at the same time? Is there a way to force the BASH script to finish its work before launching again, in the event of multiple requests?

View 6 Replies View Related

Software :: Rsync Behaves Differently Under Cron And Under My Normal Environment

Mar 16, 2010

I am making a backup on an ntfs disk, mounted with:

using the following command:

Running this (or rather the shell script containing it) from the command line is OK, but if I run it as a cron job, I get thousands of messages:

(without line breaks, actually).

These files are all ordinary files made under Windows; the above should read "offici�le stukken", and from the command line it does, but not in cron.

I guess I need to set an environment variable, but which one?

View 1 Replies View Related

General :: Loading A New Kernel In A Chrooted Environment

Aug 30, 2011

Is it possible to load a new kernel while in a chrooted environment. Say I have one linux distro and want to chroot into another and load its kernel

View 1 Replies View Related

Software :: Can Run Any Graphical Apps Without Loading Desktop Environment

Feb 5, 2009

In programming sense what is Desktop ?I can run any gnome apps using terminal or "Run Application" ?Such as , to open terminal i can type gnome-terminal and it invokes. What is Xwindow , xserver and Why do we need Gnome , KDE etc ?Why i cannot launch any graphical application [ firefox as example ] without loading xserver ?? I donot need wallpaper , start menu bla bla .. I only want to run any graphical applictaion using default black terminal.

View 4 Replies View Related

Ubuntu :: Rsync Bash Script Different In Cron?

Feb 19, 2010

I've got a bash script that uses rsync via SSH to back up data from a remote webserver.
This script works fine when I run it myself but when it runs as a cron job I get the following error:

Code:
2010/02/20 08:15:01 [6786] Unexpected remote arg: user@www.server.com:~/www
2010/02/20 08:15:01 [6786] rsync error: syntax or usage error (code 1) at main.c(1219)

[code]....

View 9 Replies View Related

Programming :: What Is Called The Old Style Of The GUI Interfaces

Nov 27, 2010

I'm wondering about this kind of GUI Interfaces like Slackware setup program

What is called ? Also, Can it be used with Python?

View 6 Replies View Related

General :: Why Can't Set Environment Value In My BASH Script

Jun 20, 2010

For example

Code:

I run "echo $PATH" after this script. The "/opt/bin" don't append to "PATH".

View 4 Replies View Related

Ubuntu :: Bash Script Works Partially In Cron?

Sep 24, 2010

I have a script that pops up a jpg file several times a day as a reminder. The script is called up by crontab and it works perfectly.The issue is that I want the script to also perform a system "beep" in addition to popping up the jpg file. When I test it on the command line everything works but when I run it in cron the jpg file pops up but the beep doesn't beep. I'm thinking the problem is in the "echo -e \a" part. I must be missing something.Here is my script:

#!/bin/bash
echo -e \a
sleep01; echo -e \a

[code]....

View 8 Replies View Related

Ubuntu Servers :: Bash Script Error - Cron Job

Nov 13, 2010

Code:
#!/bin/sh
chown -Rc steven:users "/home/steven"
I have more lines in the script but each line does the same error. This is run in a cron job but it always returns.

Code:
chown: cannot access `/home/steven
': No such file or directory
But it is a valid directory I have even tried adding an / and even a space on the end and still same error.

View 7 Replies View Related

Ubuntu :: Cron Ignores Bash Script Variables

May 4, 2011

I have a personal server and a dynamic IP address, so I wrote a script to check the currently assigned IP address and compare it to the one stored in a file from the last check, and visit the update URL if it's different.

View 4 Replies View Related

General :: Bash Script Works In Terminal But Not In Cron?

Feb 17, 2011

I'm really running into a wall trying to figure this out. I have a Bash script and narrowed down the one command that doesn't seem to work via cron and it's my pgp decrypting line. Works fine if I run the command via terminal but if I run it via cron it doesn't output anything.crontab -e shows the cronjob and it runs, creates the log file with no output. Is there maybe something I need to run as well? Permissions look set, unless the cron is running as a different user(was under the assumption if it showed up under crontab while logged into that user, then it would run as that user.

View 14 Replies View Related

General :: BASH Script Will Not Get Use Result Of Command When Run As Cron Job?

Jul 1, 2011

I am frustrated by running a script on the Fedora 14 computer as a cron job. I paste the code:

Code:

#!/bin/bash
#a backup script to copy data from sda to sdc
ROOTVOL=`blkid -U ea210a08-6212-4dc8-be1c-23fce3b965bc`

[code]....

So when I run this as root, for example:

Code:

# /root/myscript

the result is what I expect:

Code:

Jul 1 13:41:16 svn root: ADMIN: Executing backup-svn
Jul 1 13:41:16 svn root: using blkid ea210a08-6212-4dc8-be1c-23fce3b965bc as /dev/mapper/vg_svn_backup-lv_root

[code]....

View 3 Replies View Related

General :: Concatenate Two Environment Variables In Bash?

Nov 9, 2010

How do I concatenate two environment variables in bash?

View 3 Replies View Related

CentOS 5 :: Bash Script Under Cron Produces Broken Pipe

Apr 20, 2011

I have script which does file locking via flock and then writing it's pid into that file. It perfectly works being run by hand in terminal, running under cron on Debian, but somehow fails being run under cron on Centos 5.6. Script part and straced outputs are below.

bash code:

#setting lock
mylog "setting lockfile $LOCKFILE"
exec 200<> $LOCKFILE

[code]....

View 4 Replies View Related

Programming :: Function Successfully Called But It Did Not Run Device Properly?

Jan 6, 2010

I have our own C written program code which is communicating with a third party C++ written program code to run a moving device. We have successfully communicated with the third party code with wrapper functions. (Thanks to member in LQ that helped me solved this.)Now, we tried to run some functions to move the device. I think it is better for me to attach the related code first. pro.c (The source code we used to run the device)

Code:
#include<stdio.h>
#include "wrapper.h"

[code]....

View 7 Replies View Related

Programming :: Terminate Called After Throwing An Instance Of 'std::bad_alloc'

Jul 13, 2010

I have written a code in which i have used vectors:

vector< vector<double> > arr;
arr.resize(x,vector<double>(x,0));

x is a variable which is taken from a very beg text file > 64MB

first line of my code is
cout<<"
Wait Running...";

my code takes text file as an input, takes its data and generates an output text file....

Code is running fine for small data tried till x= 10

but while trying to run with large data ie x = 5000000 approx it is giving error
Even the first line of the code is not displayed. NOTE: variable is declared global but its size is defined in main.

The error that i am getting after approx 2-3 minutes is:

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Wait Running...Aborted (core dumped)

View 6 Replies View Related

Programming :: What Is The Terminology Called Of A Binary Using A File That Is Not Part Of It's Self

Feb 14, 2011

What is the Terminology called of a Binary using a file that is not part of it's self? An example would be when a browser uses a HTML file for it's interface. The binaries code has to know how to find it and so on. I imagine that the applications binary uses a system call and that another application takes over.

View 1 Replies View Related

Programming :: Wrote Code For An Application Called Nagios?

Sep 3, 2010

I suspect this will be beyond my abilities but thought I'd give it a try. A few months ago I wrote code for an application called nagios which would send me tweets when a system within my network ran into a problem (code below):

Code:
define command {
command_name notify-host-twitter

[code]....

View 7 Replies View Related

Programming :: Using Command-line Options With A Program That's Called Using Env

Oct 11, 2010

I thought about this a while ago when reading through a Python tutorial and I googled some and couldn't find an answer. Now I want to know it for Ruby, also, and it's more important now because I want to invoke Ruby with -w.

How can you use:

Code:

with a -w option to ruby, like:

Code:

This doesn't work and I can't find an explanation of how to do it.

Code:

View 1 Replies View Related

Ubuntu :: Get Cron To Run A Bash Script Every 15 Minutes To Change Desktop Background?

Jul 11, 2011

I'm trying to get cron to run a bash script every 15 minutes to change my desktop background

running crontab -e I added

Code:

*/15 * * * * sh /home/ME/Documents/scripts/background.sh

(at first i didnt have the sh before the path of the script but read somewhere i needed that) But it doesnt seem to be running my script works fine if ran straight from the terminal so Dont think thats the problem.

View 9 Replies View Related

General :: How To Go Back Or Forward A Word In Bash Environment

Mar 3, 2010

How can I move around the bash commandline efficiently?In the Windows prompt, one can go back or forward one word by pressing ctrl and <-/->.What's the equivalent in a bash environment?

View 1 Replies View Related

General :: Which Environment Variables Not Inherited By Bash Shells

Jan 2, 2011

I am using Linux some years, but since I built a LFS, I feel noobish again. Now with the help of BLFS I am setting up my environment and somewhere I incidentally read, that not every variable is inherited by a child Bash shell. As for the $PS1 and $PS2 variables I know, that they are not inherited by non-interactive Bash shells (and there is no reason why they should in my opinion). Well, as for my first thread I hope the title gives enough information on what I want to know. But anyways: Which environment variables are not inherited by Bash shells?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved