General :: .sh Script Won't Tar When Run From Cron
May 8, 2011
I'm having a script / cron problem. i'm trying to run a script that backs up a postgresql database using a pgdump command.
I've included a simplified version of my script here.
The pgdump works fine, and outputs an SQL file.
The problem is with the tar command. it fails to correctly tar, and then compress, the .sql file when the .sh script is run from cron. but when run manually from command line (with sudo) it works well. Note ls -l printout, where the top lines were generated by cron (and tar & tar.gz are minisule), whereas in the second group the tar and tar.gz are much larger (and correct).
Note that the .sh script is owned by root, who is also the user in the cron entry. I tried using postgres as the user for all those, but i think i then had password problems. should i be using some kind of "credential"?
Here is the script and cron entry (cron in test mode to produce every 2 minutes):
Code:
View 1 Replies
ADVERTISEMENT
Apr 29, 2011
Can anyone tell me how i change the default domain name for cron?everything i cron runs it emails from and to user@com.com
this leaves me with a massive list of failed mails in postfix.i have mailto on my main crontab but i cant do it on all of them.
View 1 Replies
View Related
Jan 29, 2011
I have added some executable scripts to /etc/cron.daily but don't get the stdout/stderr output from them as mail (or anywhere else I have found). At least one of them is running (because I can see that it has added a file to the disk).
The peculiar thing is that I do get the output from /etc/cron.daily/0logwatch (part of the logwatch package) as an email each day.
The MAILTO line in /etc/crontab is "MAILTO=root" (unchanged from default). Same for /etc/anacrontab.
I do have an alias at the end of /etc/aliases which redirects root's mail to my own account, but this alias works fine for mail I send manually. (It also appears to work fine for the output from the file /etc/cron.daily/0logwatch.)
View 3 Replies
View Related
Feb 25, 2010
It seems that cron is not upgrading my Ubuntu 8.04 LTS Server, no GUI installed. I changed /etc/crontab and watched apt running:
Code:
ps -A | grep apt
showed it for a long time,
Code:
sudo tcpdump tcp
showed communication with canonical sites,
but:
Code:
top
did not show any apt using CPU
[code].....
View 2 Replies
View Related
Sep 19, 2010
I put in my cron entries to run my backup script which rsyncs my data to my 2nd drive, however on a hunch I checked my backup drive which mounts automatically via fstab and I realize it had not ran in a while. I checked cron and there were no entries for it. I got to wondering if I should ever be worried about a cron update coming down and over-writing my existing cron file with the backup entries in it to run.
View 2 Replies
View Related
Feb 16, 2010
I have set up a cron in /var/spool/cron/root
*/15 * * * * /usr/bin/phplist.sh
I can see in /var/log/cron that it is running every 15 minutes but it has no effect. It is not doing the commands in the bash script.
If I run /usr/bin/phplist.sh right in the shell it works great.
View 3 Replies
View Related
Feb 9, 2011
Is my vixie-cron broken? i have "0-59 * * * * root /usr/sbin/logrotate /etc/logrotate.conf" but it is not running in /etc/cron.d.
Code:
View 2 Replies
View Related
Oct 28, 2009
I have a php script that checks versions of a remote stock file every 15 minutes. When it discovers that a new version is available it downloads the new file and runs it through a series of scripts that prepare it for an e-commerce application. It takes about an hour to import the file and process it. Otherwise, it echos "file on remote host not newer than local file". The stock file is updated every 3 or four hours and it's never at the same time. So we would like to run this script every 5, 10, or 15 minutes to make sure we have updated files.
So what happens when my php script finds a new file and takes an hour to do its work? Will the cron be activated three more times during this span? In other words, will it keep starting over even if its still running from a previous cron? Is there a way to stop the cron from running while the file download and processing occur, and then resume when its finished?
View 6 Replies
View Related
Mar 17, 2010
How can I run a scheduled job in a specific hour minute second (hh:mm:ss) I tried "at" but I do not know how to send it "seconds".
View 5 Replies
View Related
Jun 24, 2011
i want to run my cron every day at 4:30am
304***php /home/lfncltee/public_html/Center/all_in.php >/dev/null 2>&1
View 2 Replies
View Related
Feb 17, 2010
I'm trying to run a php script from a cronjob and can't seem to get it working.
When I run the script from the shell command prompt:
The scripts works fine
I then inserted a cron job using:
And inserted the following:
And nothing seems to happen.
I left off the -q and have a few echo commands within the script but I don't get an email of the output either.
View 3 Replies
View Related
Apr 6, 2010
I am trying to set up a script that uses SCP and will run via cron to go out 3 nights a week and pull down the zip files that are created of my website on my hosting server. I am having trouble setting up the SCP script that will automate this. I don't want to have to enter a password each time. I know this can be done with public/private keys but need help with the syntax. Below is an example of what I have.
scp -i /.ssh/authorized_keys.pub usernameremotehost:/public/backups/*.t.gz /public/backups/
View 3 Replies
View Related
Jan 9, 2011
I have a cron job to schedule the task on the third sunday of the month.I saw the previous threads but didn't find any solution.
How the cron syntax can be written.
View 14 Replies
View Related
Dec 8, 2010
I have two shell scripts, one has to run after the other has finished running.I know that in cron.monthly they run in alphabetical order, but does each one run after the other has completed, or is it possible that the first may still be processing when the second is run?
View 1 Replies
View Related
Mar 14, 2010
I know that Redhat have a log in /var/log/cron , I can check the cron job log here , I would like to ask where is the log in Debian ?
View 1 Replies
View Related
Jun 7, 2010
I would have sworn this used to work, but now I'm not so sure.
I have a script that I want to run on the last day of every month. So, I have this as a cron job:
Code:
0 23 28-31 * * [ `date +%d` -eq `echo `cal` | awk '{print $NF}'` ] && /path/to/script
But it fails. I get mail that says:
Code:
command failed with exit status 1
/bin/bash: -c: line 0: unexpected EOF while looking for matching ``'
/bin/bash: -c: line 1: syntax error: unexpected end of file
I tried a slightly different syntax:
[Code].....
View 3 Replies
View Related
Jun 24, 2010
I have a simple script. When I run it as cron job. I jot email saying:/bin/sh: line 1: test.tmp: command not found.Even I took first line out, I got the same error.The current shell I have is /bin/tcsh.
View 4 Replies
View Related
Jul 24, 2011
The problem is I need the php program to send member email confirmation which contains a confirm link. Run every min may still make the member wait. So I like to make it to run every 20 or 30 secs.
I don't want to put the code to send email on my sign up page as that's no good.
But I don't want to put a sleep 30 sec on my php script and going on loop. If it failed in the middle then it may wait abit to start.
What can be done to achieve my goal and what's the best way?
Making a php script to run as a daemon process? Is that possible and okay?
View 9 Replies
View Related
Jun 8, 2009
Maybe this is a MySQL question, maybe not...
I've written a shell script to back up a database.
But when I run it, it prompts for password even though the script provides it. If I'm doing this manually, it's not a problem, but I want to make a cron job to do it...
Here's the script: Quote: #!/bin/bash
set -xv
#First let's rotate the backup files...
/bin/mv /home/cabazio/someDB-3.tar.gz /home/some/someDB-4.tar.gz
/bin/mv /home/some/someDB-2.tar.gz /home/some/someDB-3.tar.gz
[Code]....
View 2 Replies
View Related
Mar 30, 2010
Is there a command that can be run to verify that a users cron job has run successfully?
Platform is Ubuntu 8.04 LTS.
I have scripts in /home/useraccount/bin/
running
crontab -l
While logged in as user results in:
# m h dom mon dow command
@hourly /home/useraccount/bin/script_1
@hourly /home/locateruser/bin/script_2
I realize scripts could send email or write to a log with a timestamp, but wondering if there is just a way to verify it ran from the command line.
I ran
ps -ef|grep cron
... and it shows
root 4358 1 0 Mar12 ? 00:00:00 /usr/sbin/cron
Not sure if this indicates it is running the jobs though....
View 4 Replies
View Related
Jul 12, 2010
I need to run a script when i login for first time in a day. I may reboot or shutdown and then power on during the day. But i do not want the job to run during those power ups. It should run only once per day.
View 3 Replies
View Related
Oct 28, 2010
I have a cron job that executes a rake task in rails. I noticed in the log that it was running the task 4 times everytime it was executed. The problem is that there are 4 instances of cron running.
I ran code...
So my question is how do I stop the other instances. When I run the stop command now I get this:
Stopping crond: cannot stop crond: crond is not running. [FAILED]
Any ideas? Do the other instances have different names? Is there a way to kill all instances as once?
View 2 Replies
View Related
Feb 10, 2011
Is there a way for me to tell cron to run an app BUT not run it if a process exist already?
View 5 Replies
View Related
Jul 19, 2010
I have a friend who needs a script to reboot a system every 5 min... not sure how to set cron to do this every 5 min.
View 1 Replies
View Related
Jan 5, 2011
I'm having a small issue where the backup jobs that I set to run in the crontab of the backup user do not appear to be running. Here's how I set it up (with crontab -e as the backup user):
run amanda every night (check at 2:45 and backup at 3)
[code]...
View 5 Replies
View Related
Oct 15, 2009
I have 3 cronjobs set up on my Unix server . Out of which 2 cron jobs run the same script but at different times and the other one runs another script.
So in the 2 jobs which are set to run PMDaily.sh for eg , One runs on Sunday at 8AM and the other runs monday to friday at 6 AM . How ever the Sunday cronjob works (runs through the crontab) but the Cron job set for Monday to Friday is not working. However manually if i run this script it workd perfectly.
Please let me know what could be the possible reasons for this?
View 2 Replies
View Related
Dec 14, 2010
if i do a
ps aux | grep ftp
that would show me at least any active ftp connects started with the ftp command, right? Is there then a way to use that to somehow kill any stuck sessions that are older than an hour?
View 9 Replies
View Related
Feb 21, 2011
How to create a cron file that will regularly perform the following backups:
a. Performs a level 0 backup once per month
b. Performs a level 2 dump one day per week
c. Performs a level 5 dump every day that neither a level 0 nor a level 2 dump is performed.
In the worst case, how many restores would you have to perform to recover a file that was dumped using this schedule.
View 4 Replies
View Related
Aug 6, 2010
i want to install new softwares using cron , i tried shell script : apt-get -y install packname and run the script using cron. it is not working so then i installed cron-apt but i am not able to understand how to use it
View 7 Replies
View Related
Mar 10, 2011
iam try to schedule my job in a file made in /etc/cron.d file as follows* * * * * tomcat6 /home/etika/Desktop/eka.sh /home/etika/Desktop/ea/etika.txt abc@gmail.comwhere eka.sh belongs to etika which is the root and etika.txt belong to tomcat6 this command is not running iam confused about the name of the owner written after the *'s please tell me whose name is written after the *'s(the schedule of the script) the owner of the script or the owner of the file which iam passing as an argument to the shell script
View 2 Replies
View Related