I have a working bash script to do backup - it runs fine from the terminal. During the backup it makes a log file in my home area. I transferred it to root, and set it up to run as a cron job as root. It runs fine as long as I am logged in with my normal user name. It does not run if I am not logged in. Logs show the script was called by cron, but there is no output and no backing up is done.
Here is the script
Code:
#!/bin/bash
for i in `cat /proc/mounts | cut -d' ' -f2`; do
if [ "$i" = "/media/Elrond" ]; then
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.
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.)
I've been trying to accomplish this on my own, but I can't seem to figure it out...
All I'm trying to do (for learning purposes) is to get a message to print out to a log file every 5 minutes.
This is on Ubuntu Server 6.06.
Logged in as root ( I know, I know, should have sudo'd, oh well... )
Created a new file with this in it:
Code:
Added this line:
Code: ( I wasn't sure the proper command to try every 5 minutes, but this is my latest iteration. I also started with just */5, and that didn't seem to work either. )
Saved and exited crontab.
Console reports:
Quote:
Using command: ps -ef | grep cron
Quote:
So I waited 10 minutes to be safe.... and saw no log file appear.
I checked this page here: [url]
I wasn't sure what it meant by the PATH= variable they wanted me to set, my /etc/crontab file states:
Code:
But I didn't know if it meant there, or in my crontab -e location, so after the first failed attempt, I added the line from that webpage as well to crontab -e:
Code:
Waited another 10 minutes to be safe, still nothing.
why my second cron job isn't running? The first one runs fine but the second one does not run at all. If I manually run the script using ./check.sh then it does what it is supposed to but will not run from cron. It should run every weekday at 9:45am, it looks good to me but clearly I am doing something wrong.
Code: # m h dom mon dow command #This will backup my hosted websites. 0 2 * * * /home/bob/scripts/websitebakscript.sh #This will run check and upload it's contents to the net. 45 9 * * 1,2,3,4,5 /home/bob/scripts/check.sh
Cron refuses to work for a newbie.I am trying to setup a cron job to backup a folder in my home directory ('/home/scratch') to a folder ('home/internet_backup') that is mounted (using nfs) to a network folder.the folder ('home/internet_backup') is mounted correctly to the network folder upon system startup, so this part works.
When I refresh the page 'updatestatistics.php' in my webbrowser it does generate a new page ('statistics.html', which is included in 'statistics.php'). But when I let this cron job do the job, nothing happens. I looked into the log file, it shows this:
After saving a few sample scripts in crontab, I discovered that cron is not running properly on my Ubuntu 9.10 (32 bit), after a recent reinstallation. Please note that the files "/var/log/cron" and "/etc/defaults/rc.conf" are empty in my system.
I'm trying to get this script, which normally works fine, to run from cron. This is far from my first custom cron script, but it's the first to give trouble! I've added PATH directives (never had to do that before) but it still didn't work. I also tried setting absolute paths, that didn't help either. If I add a line that echoes a string to a file as a test at the end of the script, the file appears, so I know the script is executing, it just looks like the cpufreq-set commands aren't working. The purpose of this script is to adjust the maximum SpeedStep setting on my now passively-cooled home server to keep the CPU from getting too toasty.
Code: #! /bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin # set temp above which to drop the maximum frequency scaledowntemp=`echo -n "62"` # set temp below which to reset the maximum frequency scaleuptemp=`echo -n "59"` # get cpu temperature cputemp=`sensors | grep "Core 0" | gawk '{print $3 }' | sed -e 's/+//g' | sed 's/....$//'` if [ $cputemp -lt $scaleuptemp ] # if temp is in acceptable range, set max frequencies free then cpufreq-set -c 0 -u 2.81Ghz cpufreq-set -c 1 -u 2.81Ghz fi if [ $cputemp -gt $scaledowntemp ] # if temp is too high, limit cores to 1.6Ghz then cpufreq-set -c 0 -u 1.61Ghz cpufreq-set -c 1 -u 1.61Ghz fi
I have this in my crontab (along with another line before it):
Code: * * * * * /bin/echo "Does this work?" > ~/test ...and the file doesn't show up. I have a blank line after that one in the crontab. I have no /etc/cron.allow or /etc/cron.deny files. I'm running Ubuntu 11.04. /var/log/syslog shows "BEGIN EDIT" and "END EDIT" etc. when I run crontab -e, but doesn't say anything about trying to run commands. Anything I might be missing?
I've setup a cron job to run every day at 13:00. When I run it manually it works but with the cron it doesn't
this is the log:
Code: Jun 14 13:00:01 testserver CRON[5662]: (scialom) CMD (lynx http://www.something.com/sms_reminder.php # JOB_ID_4) Jun 14 13:00:02 testserver CRON[5661]: (CRON) info (No MTA installed, discarding output) Jun 14 13:00:08 testserver dhclient: DHCPREQUEST of 10.0.0.6 on eth0 to 10.0.0.138 port 67 Jun 14 13:01:14 testserver dhclient: last message repeated 4 times
Cron for root does not run,it's 8.04LTS ubuntu server,however Cron runs for other users,Can anyone help?i've checked many times that i have the right syntax.
I have a cron job set up to backup my ~/ directory everyday at 10:00. But the cron job is not running. here is my confile that I loaded into crontab...
Code:
#backup everyday @ 10:00 AM and 10:30 AM 00 10 * * * /home/dave/bin/backup.sh 30 10 * * * /home/dave/bin/music_backup.sh
[code]....
the *.sh are executable. I logged out and logged back in since I put the cronfile in crontab. The commands that I use in the *.sh files work fine when I run them manually.
I seem to be having a problem with cron. I have a python program that checks a specific directory for pending email scripts written in python.
Code: #!/usr/bin/python import os emaildir = os.environ['HOME']+"/email/" filelist = os.listdir(emaildir) for pyfile in filelist: if pyfile.find(".py") > -1: execfile(emaildir+pyfile)
This code has been tested and works fine. The problem is that I need cron to run this code every 5 minutes but i can't tell if it is running: Here is my cron code: 5 * * * * /home/username/custom/CheckEmail.py >>/home/username/custom/email.log 2>&1
I activated the log (I think) but all i get is /var/log/cron.log and that only logs when I activate/deactivate or edit the cron file. is there anything else i need to set for this to work? I am running Ubuntu 9.10.
When I run this this script in bash it works perfect. When I run as a cron job it starts but never finishes. The reason I know it starts is because a temp file is started by zip but never is completed.The funny thing I was running Linux Mint 8 and this worked fine I just switched to Ubuntu 10.04 & bang no good ..
Crontab -l Output --> # m h dom mon dow command 18 21 * * * /home/joe/Scripts/./BU
i am very sorry if this has been asked before... i'm sure it has.. but i have searched all over the net looking for an answer and i still cant find it...
I have a really simple cron job script like this:
When i run this manually it works fine but when i run it from my ROOT user in Plesk as a cron task is always creates a file that is just 45 bytes. Why doesn't it work... I am running it as a root user.. so surely i must have permission to access the file?
I have a script that I would like to run using 'cron'. I want to use 'scp' to transfer files from one machine to another. I have set up the SSH keys on both machines. When I run the script from bash terminal, it works flawlessly. But when I schedule a 'cron' job to run the same script, 'scp' does not transfer the files.
'Return value' is 0 when the script is run from bash directly. But when it runs from 'cron', the 'Return value' is 1. That means, surely, that 'scp' is throwing an error. I don't know which error is being encountered. Could anybody let me know how to make it work?