Cron job error
I get this message in my local mail:
Subject: fcron <systab@morgana> /usr/sbin/run-cron /etc/cron.daily
Date: Wed, 21 Dec 2011 00:02:47 +0200 (EET)
From: [email protected] (fcron)
Status: R
col: Invalid or incomplete multibyte or wide character
it's an error in one of cron.daily scripts. the only cron jobs were installed by packages:
[root@morgana ~]# ls -l /etc/cron.daily/
total 20
-rwxr--r-- 1 root root 51 Sep 28 08:52 logrotate
-rwxr--r-- 1 root root 807 Jun 4 2011 man-db
-rwxr--r-- 1 root root 115 Sep 10 03:42 pkgfile
-rwxr--r-- 1 root root 96 Dec 4 03:13 shadow
-rwxr--r-- 1 root root 654 Apr 9 2011 updatedb
I'm quite sure that man-db is having troubles. Also, I replaced default cron with fcron, same thing happens (I like fcron more anyway). Maybe it's locale related? I use en_US.UTF-8 in rc.conf and uk keymap. locale.gen only has the defaults, en_US.UTF-8 UTF-8 & en_US ISO-8859-1.
I have no idea what's wrong. Any ideas please? Thanks
It appears one of your scripts is corrupt. Try running it through iconv to see if there is a bad byte sequence.
$ iconv < /etc/cron.daily/man-db > /dev/null
Similar Messages
-
Shell Script gives error when run through cron job.
Hi,
The following shell script runs without any problem when executed manulally.
USED=$(df -h /arch | tail -1 | awk '{print $5}' | cut -d '%' -f 1)
if [ ${USED} -gt 90 ]
then
find /arch/AUBUAT/ -type f -mtime +0 | xargs rm
find /arch/AUBMIG/ -type f -mtime +0 | xargs rm
fi
But the same gives below error when called from a cron job:
/backup/arch_test.sh: syntax error at line 1: `USED=$' unexpected
We are running following version:
bash-3.00$ uname -a
SunOS uaeaubdbdr01.aub.af 5.10 Generic_141444-09 sun4u sparc SUNW,SPARC-Enterprise
Kindly assist.
Thanks
Edited by: user13362786 on Apr 20, 2011 4:36 AMHi,
When I used #!/usr/bin/sh now even the manul execution of the script fails with the same err:
bash-3.00$ ./arch_test.sh
./arch_test.sh: syntax error at line 2: `USED=$' unexpected
And when I used #!/usr/bin/ksh the manual execution runs fine but again when the script is run from cronjob it now give dirrect err:
/backup/arch_test.sh[2]: df: not found
/backup/arch_test.sh[2]: tail: not found
/backup/arch_test.sh[2]: cut: not found
/backup/arch_test.sh[2]: awk: not found
/backup/arch_test.sh[3]: test: argument expected -
Cron job not running - script uses rsync, ssh (with id_rsa)
Does anyone know how to get cron to run a rsync/ssh script which uses id_rsa for passwordless logins?
I have a backup script I have slaved for months over that works wonderfully when running it from the command line.
It uses rsync and connects with SSH (passwordless using ssh keys). I have setup id_rsa and id_rsa.pub for passwordless logins (this is my user account, and connects using root@ to the server)
As stated all works find when run from the command line. But when I setup a cron job to run this file (exact same line I run from the command line) it does not execute. Actually, it does run, as I have an email notifiction which sends to me. It is just the rsync/ssh part that does not run.
I have spent days and days trying to figure it out. No error messages occur, nothing. Took me a while to find out cron is emailing the user account on Lion the messages (not to a proper email address).
The error shows a permission denied, which I believe to be the cron user cannot use the id_rsa/ssh connection.
Cron is running the script as my user, the same I use on the command line. I even tried copying the id_rsa to the root user .ssh folder in case cron is running as root but that does not work either.
So does anyone know how to get cron to run this rsync/ssh script which used id_rsa for passwordless logins?
Thanks a lotYES! Got it working, finally!
So the issue is indeed cron/launchd not being able to access the ssh-agent which holds the key.
So this is the solution...
Download keychain for Mac:
http://www.funtoo.org/wiki/Keychain
Then once its installed and configured, the script to run needs this added to the top:
eval `keychain --noask --eval id_rsa` || exit 1
Note I am using id_rsa whereas keychains instructions refer to id_dsa so I just changed it and it works OK.
When the script runs the first time it asks for the key password. Then it works from then on.
What I do not know yet is will I need to re-enter the password when I logoff/logon again. That will cause an issue as I auto restart the Mac every day which means if I am off for a few days backup will stop (can you see the madness in this issue!). -
EJB Persistence using cron job
We have a EJB based bean managed persistence classes that run on the app server. I want to use same classes using cron job.
How do I do that???
Tried to execute these classes thru following steps...
In side stand alone java class - main method create instance of the pmf and get persistence manager.
Start a tread and call JDO object using persistence manager.
getting whole bunch or errors like system-server-config.xml file not found. I am not able to create InitialContext outside app server.
Please give your suggestions. TIAWhy don't you use a J2EE based scheduler?
http://java-source.net/open-source/job-schedulers/quartz
http://java-source.net/open-source/job-schedulers/jcrontab -
[Solved] Have Cron Job Open Terminal Window
I want to run a ping script every morning to check the liveliness and latency of specific servers. The script itself works fine but I can't figure out how to have cron open up a terminal window so I can see the script running.
This is what I have so far:
#runs /home/bran/pingservers.sh everyday at 8:30 am
10 10 * * * env DISPLAY=:0 konsole -e ~/pingservers.sh
But it doesn't open anything I don't even know if the job is even executing.
Last edited by brando56894 (2013-05-20 14:25:42)I am unsure how to get the script to open a terminal, but the journal should have some information on whether the script is running or not and if there are any errors.
brando56894 wrote:
I don't even think cron jobs are running at all. I changed my job to
1 * * * * /bin/echo hello world
and it hasn't done anything...
As far as the job above, I just wanted to note that you have it set to run on the first minute of every hour. If you were looking for every second minute, you would want the following:
*/1 * * * * /foo/bar
Last edited by BluMongoose (2013-05-14 22:01:48) -
Hello,
Which is the best way to create a cron job for a sql script?
Thank you!1) each time you change your cron settings, add a job, delete, etc. save the latest state into a text file, dated. this way you have a log of changes. Example:
crontab -l > cron.mmddyy
2) make sure you have standard include files that contain all the environment (ORACLE_HOME, ORACLE_SID) and user names+passwords. These should be kept separate from the scripts, so that:
- you can include them in all scripts
- apply strict security access
the script can apply the env files to get the info. same as you apply the "oraenv" command in your shell prompt.
3) make sure each cron job leaves a detailed log, including errors. Examine the logs on a frequent basis. The shell script should try to catch errods and email them to the admin whenever possible. Example:
0 0 * * * /folder/script.sh /folder2/script.env > /folder3/script.log 2>&1 -
How we can tell which cron jobs are running and how to start/stop them, give me example/command plz
I do not know of any articles off the top of my head, but just remember if you can create a non-interactive script to do the job then you can run it as a cron job.
Here are several types of cron jobs that we currently use:
1. Kick off nightly hot and weekly cold backups.
2. Gather statistics weekly (on just some databases)
3. Gather performance statistics (perfstat) when wanted.
4. Perform audit gathering/deletion jobs.
5. Check for errors in alert logs and trace files and send out emails if needed.
6. Check status of listeners and database processes to assure they are still running.
7. Move log files to archiving storage
We are going to eventually move a lot of these jobs to OEM Grid Control but until then cron is great.
Regards
Tim -
Suppress cron from logging a cron job
I have a cron job that I'm running once per minute. I don't want to have the /var/log/crond.log get updated 60 times per hour. How can I suppress the logging of the job?
I've tried adding the following to the cron line but they just get logged right along with it!
*/1 * * * * /path/to/script > /dev/null
*/1 * * * * /path/to/script > /dev/null 2>&1@st - I can change the /etc/conf.d/crond to a lower level (default is CROND_ARGS="-S -l info") but I'm only interested in stopping the activity for a specific job; changing it from info to notice will be a global setting.
* debug - Debug level message
* info - Informational message
* notice - Normal but significant conditions
* warning, warn (depreciated) - Warning conditions
* err, error (depreciated) - Error conditions
* crit - Critical conditions
* alert - Action must be taken immediately
* emerg, panic - System is unusable
Last edited by graysky (2010-12-24 20:01:59) -
How to suppress "exit status 0" log mail for cron job
Hello,
we have a shell script to collect stats every day. it is croned.
Recently, in the moning, get email to say "Output from cron job xxxx, in server xxx, exit status 0",
As we know, the job is done well everyday without error(exit 0), but my question is how to let server to stop sending this useless alert email everyday.
any trick?
thank you.
cc: the script
case $1 in
-? ) cat $0 | grep "#H" | grep -v "grep"
exit
esac
case $1 in
-? ) cat $0 | grep "#H" | grep -v "grep"
exit
esac
if [ -n "$1" ]; then
ORACLE_SID=$1
else
return
fi
if [ -n "$2" ]; then
SCHEMA=$2
else
return
fi
TOOLS=/opt/dba/oraadmin/tools
TABLE=xxx
COLUMN=xxx
. /opt/dba/oraadmin/tools/ora_env.sh -S $ORACLE_SID
LOG_FILE=$SVR_LOG/dbms_stats_xxx.log
echo $LOG_FILE
$ORACLE_HOME/bin/sqlplus '/ as sysdba' << !EOF > $LOG_FILE
set echo on;
exec dbms_stats.gather_table_stats('$SCHEMA','$TABLE');
exec dbms_stats.gather_table_stats('$SCHEMA','$TABLE', method_opt => 'for columns $COLUMN size 1', cascade => FALSE);
DECLARE
n_distcnt NUMBER;
v_Owner varchar2(100) := '$SCHEMA';
v_TABLE_NAME varchar2(100) := '$TABLE';
v_COL_NAME varchar2(100) := '$COLUMN';
BEGIN
select round(num_rows/3,0) into n_distcnt from all_tables where owner = v_Owner and table_name = v_TABLE_NAME;
--and then just set statistics
DBMS_STATS.set_column_stats (v_Owner,
v_TABLE_NAME,
v_COL_NAME,
distcnt => n_distcnt);
END;
exit;
EOF
Edited by: 795980 on Aug 2, 2011 7:43 AM795980 wrote:
Hello,
we have a shell script to collect stats every day. it is croned.
Recently, in the moning, get email to say "Output from cron job xxxx, in server xxx, exit status 0",
As we know, the job is done well everyday without error(exit 0), but my question is how to let server to stop sending this useless alert email everyday.
any trick?
thank you.
cc: the script
case $1 in
-? ) cat $0 | grep "#H" | grep -v "grep"
exit
esac
case $1 in
-? ) cat $0 | grep "#H" | grep -v "grep"
exit
esac
if [ -n "$1" ]; then
ORACLE_SID=$1
else
return
fi
if [ -n "$2" ]; then
SCHEMA=$2
else
return
fi
TOOLS=/opt/dba/oraadmin/tools
TABLE=xxx
COLUMN=xxx
. /opt/dba/oraadmin/tools/ora_env.sh -S $ORACLE_SID
LOG_FILE=$SVR_LOG/dbms_stats_xxx.log
echo $LOG_FILE
$ORACLE_HOME/bin/sqlplus '/ as sysdba' << !EOF > $LOG_FILE
set echo on;
exec dbms_stats.gather_table_stats('$SCHEMA','$TABLE');
exec dbms_stats.gather_table_stats('$SCHEMA','$TABLE', method_opt => 'for columns $COLUMN size 1', cascade => FALSE);
DECLARE
n_distcnt NUMBER;
v_Owner varchar2(100) := '$SCHEMA';
v_TABLE_NAME varchar2(100) := '$TABLE';
v_COL_NAME varchar2(100) := '$COLUMN';
BEGIN
select round(num_rows/3,0) into n_distcnt from all_tables where owner = v_Owner and table_name = v_TABLE_NAME;
--and then just set statistics
DBMS_STATS.set_column_stats (v_Owner,
v_TABLE_NAME,
v_COL_NAME,
distcnt => n_distcnt);
END;
exit;
EOF
Edited by: 795980 on Aug 2, 2011 7:43 AM1) problem & solution have NOTHING to do with Oracle RDBMS & is Scripting 101 Basics
2) posted script does NOT send any email so does not contribute to problem or solution.
my question is how to let server to stop sending this useless alert email everyday.The obvious solution is to NOT send the message.
code sending script to stop being a spam-o-gram generator -
Running Applescript using cron jobs not working
I'm new to conjobs and applescript but I have the script done correctly i believe. (any critique is welcome) I don't want to bloat my calendar with events to do this because I use my calendar for appointments and I don't need the bloat.
Here's my goal: run an apple script at 9am/5pm to enable/disable a mail account (after this works I'm going to add loging in/out of an Messenger account, first things first)
here's my script:
tell application "Mail"
set offTime to 17
set onTime to 9
set dayOfWeek to weekday of (current date)
set theHour to get the (hours of (current date)) as string
if theHour ≥ onTime then
say "email on"
set enabled of account "MAILBOX" to true
else if theHour ≥ offTime or (dayOfWeek = Saturday or dayOfWeek = Sunday) then
say "email Off"
set enabled of account "MAILBOX" to false
end if
end tell
accessing cron jobs via this
sudo pico /etc/crontab
and within cron jobs i've used
0 9 * * * username osacript
"/Documents/disablemail.scpt"
0 17 * * * username osacript
"/Documents/disablemail.scpt"
variations I've attempted (based on search engine results)
0 9 * * * username osacript
"~/Documents/disablemail.scpt"
0 9 * * * /Documents/disablemail.scpt
0 9 * * * ~/Documents/disablemail.scpt
0 9 * * * osacript /Documents/disablemail.scpt
0 9 * * * osacript ~/Documents/disablemail.scpt
I think that's all of them.
Any feedback/assitance appreciated, thanks!What's the problem, is the cronjob not getting called at all or is the script giving errors?
One problem you have right off is the cron job you have set up is running as root not as you. -
Are all Cron Jobs run by Root?
OS : Sun OS 5.10
I have scheduled an RMAN backup script which had only one line like
rman target .............I logged in as os user oracle and ran this script without any issue. But when i scheduled this job to run, it didn't work.
I got the error
/u05/bkp_scripts/rman-level0_WM.sh: rman: not foundThe shell couldn't find rman binary in PATH. Everything worked when i explicitly set ORACLE_HOME, ORACLE_SID, PATH in the shell script.
Does this mean a cron jobs scheduled by OS User oracle will still won't work unless you set set ORACLE_HOME, ORACLE_SID, PATH in the shell script?
Are cron jobs handled by root user regardless of who scheduled it?ExpansiveMind wrote:
OS : Sun OS 5.10
I have scheduled an RMAN backup script which had only one line like
rman target .............I logged in as os user oracle and ran this script without any issue. But when i scheduled this job to run, it didn't work.
I got the error
/u05/bkp_scripts/rman-level0_WM.sh: rman: not foundThe shell couldn't find rman binary in PATH. Everything worked when i explicitly set ORACLE_HOME, ORACLE_SID, PATH in the shell script.
Does this mean a cron jobs scheduled by OS User oracle will still won't work unless you set set ORACLE_HOME, ORACLE_SID, PATH in the shell script?
cron does not execute the user's .profile. You must guarantee your environment by setting it inside the script.
Are cron jobs handled by root user regardless of who scheduled it?NO! root should NEVER be used for Oracle tasks. root should never be used for anything that can be done by another account. -
I have a script that I wrote to backup a server at midnight every night. It uses rsync to perform the backup. The past two nights it has run it seems to cause the server to crash. I used the Terminal to setup a cron job to run the script. Does this sound like a serious error or am I doing something completely wrong, or should it maybe be done at a different time? I looked through the logs and the kernel seems to panic and call crashdump or panicdump.
The system in question is a Mac Mini if it makes any difference. If anyone would like I could post the script.
TomHere is the script file. I tried changing the time the script is run from midnight to 1AM and it ran the problem was that it ran about 60 times!!!!
Is this a problem with the cron job because I see no problems with my script. I can successfully run it from the command line.
#!/bin/bash
DIRS=(/Applications /Developer /Groups /Library "/Shared Items" /System /Users /bin /opt /private /sbin /sw /usr)
###### DON'T CHANGE BELOW HERE ######
LOGS_DIR="/Library/Logs/Backup"
MACHINE=`hostname -s`
RSYNC_FLAGS=" -avz -e ssh --eahfs --delete" # These shouldn't need changed
DATE=`date +%m%d%G`
RSYNC_BIN="/usr/local/bin/rsync"
if [ ! -d "$LOGS_DIR" ]; then
mkdir $LOGS_DIR
fi
if [ -z "$1" ]; then
echo "usage: $0 <daily|weekly>"
exit
fi
TYPE=$1
if [ "$TYPE" = "daily" ]; then
TYPE="Daily"
elif [ "$TYPE" = "weekly" ]; then
TYPE="Weekly"
else
echo "Bad Option please use daily or weekly"
exit
fi
BACKUP_DIR="146.186.147.152:/Volumes/Backups_${TYPE}/${MACHINE}/"
#echo "${RSYNC_BIN} ${RSYNC_FLAGS} "${DIRS[@]}" ${BACKUP_DIR} >& ${LOGS_DIR}/${TYPE}_${DATE}.log"
#${RSYNC_BIN} ${RSYNC_FLAGS} "${DIRS[@]}" ${BACKUP_DIR} >& ${LOGS_DIR}/${TYPE}_${DATE}.log
#echo "${RSYNC_BIN} ${RSYNC_FLAGS} "${DIRS[@]}" ${BACKUP_DIR}"
${RSYNC_BIN} ${RSYNC_FLAGS} "${DIRS[@]}" ${BACKUP_DIR} -
Sending job error message to admin by email
Hi everyone...
Anyone knows how to send job error message to admin by email? For example, if crawler failed, an email is sent to admin with the error message. I'm thinking of building windows service which run at the background and knows when a job fail and send the error message through email to admin.
Is there a better way?
Cheers,
Jefi Santosohi,
>>>Can this be achieved through BPM?
yes you can put your transformation step
and send step in a block and specify an exception
branch and catch all exceptions that will
occur during transformations and the send step
then you can send info from the exception branch to
any other system
you won't be able to catch the error's name
but you will be able to notify any thinrd party
about the error
more on error catching:
http://help.sap.com/saphelp_nw04/helpdata/en/33/4a773f12f14a18e10000000a114084/content.htm
Regards,
michal -
How to take the cron job log in HP UX?
Hi,
How to take the cron job log in HP UX
I need to run a backup and other stuff everyday. How do I check and start cron service under HP-UX UNIX operating system? How do I write cron jobs?
A. Cron service is required to run jobs and tasks such as backup.
You must login as the root to run following commands. Each user that is using the cron service must have a cron configuration file in the /var/spool/cron/crontab directory. Also users are permitted if their name appeared in /var/adm/cron/cron.allow file
Task: Find out if cron is running under HP-UX
Type the following command at a shell prompt
# ps -ef | grep cron
Open /etc/rc.config.d/cron file
vi /etc/rc.config.d/cron
Set control variable to 1 to enable cron: CRON=1
Set control variable to 0 to disable: CRON=0
Close and save the file. To start or stop cron you can type the following command:
# /sbin/init.d/cron start <-- start cron
# /sbin/init.d/cron stop <-- stop cron
Task: HP-UX Start cron service
If cron is not running, simply type:
# cron
Task: Edit / create cron jobs
Type the following command to submit a cron job:
# crontab -e
List your cron file:
# crontab -l
Backup all your cron jobs:
# crontab -l > ~/backup.cron.jobs
Remove ALL cron job:
# crontab -r
Task: Crontab file format
Cron file format is as follows:
MIN HOUR DATE MONTH DAY /PATH/TO/COMMAND
0-59 0-23 1-31 1-12 0-6 /root/scripts/backup2tape.shEasy to remember crontab file format:
* * * * * command to be executed
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)To run /root/script/backup at 23:00, every day, enter:
# crontab -e
Append following
0 23 * * * /root/script/backupRun foo job very weekday (MON-Fri) at 6am, enter:
0 6 * * 1-5 /root/script/backupFor more information refer to cron and crontab man pages.
Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.
Related Other Helpful FAQs:
What is Cron?
Linux Start and stop the cron or crond service
Run crontab Every 10 Minutes
Linux / UNIX Setup and run php script as a cron job
Stop Ubuntu / Debian Linux From Deleting /tmp Files on Boot
Discussion on This FAQDavid Says:
January 15th, 2008 at 12:21 am
You might note that all files normally found in /etc/init.d, /etc/rc*.d, and others are all in /sbin in HP-UX 10.20 and up.
Note too that your formatting is off in the description of the /etc/rc.config.d/cron file. Also, if you run /usr/bin/cron instead of /sbin/init.d/cron start, the /etc/rc.config.d/cron file is not used.
Regards,
SatyaI guess it would :)
btw, how did this piece miss from the contents pasted by the OP ?
The doc has given all details of CRON and missed where to see the logfiles. :)
****Added****
I tried man crontab in windows, i dont see it.i overlook most of the things, i would have done the same ;)
Edited by: Bobcatalog on Oct 23, 2008 9:40 AM -
What I want to do is run an Applescript every 6 hours and 1 minute. If the computer is asleep when the job comes due, I want it to execute the script and reset the counter. Can crontab do this? If so, how to set it up?
Gnarlodious wrote:
Then skip it, I can see there is no easy way.
I don't think it's that hard, though. Just a bit tricky. I was just a bit confused on what exactly you wanted.
I could write a stay-open Applescript application, but I wanted to avoid cluttering up the Dock just to run a command every 6 hours.
Nah, I wouldn't want that either.
If I were doing something like this and I wanted it to work like this:
1. Run every six hours, at 6 AM, noon, 6 PM, and midnight.
2. Run after waking up if the computer has been asleep and missed any of the times in between, say if you let the computer sleep thru the 6 AM job.
I'd do this:
1. Call the AppleScript periodically from a cron job. How often would be dependent on how tight you want the times to be to when you wake up.
2. Have the AppleScript save a text file somewhere with the time when it runs. That way, if your computer is asleep at 6 AM, the script could use this to decide if it missed running while it was asleep.
3. Have your script check this time and if it's over 6 hours, let the script do its thing. If not, then just exit, to try all this again the next time cron runs it.
Here's kind of a pseudo-code way of describing it:
check if it's 6:01, 12:01, 18:01, 00:01
if yes:
do your AppleScript business
save the current time in a file
exit
if it's not one of those times:
check if it's been over 6 hours since the AppleScript did its business
if yes:
do the AppleScript business
save the current time in a file
exit
if no:
exit
Then you could do two cron jobs:
1 */6 * * * /path/to/applescript
*/5 * * * * /path/to/applescript
The first one would run at your appointed times. The second would just run every 5 minutes to catch those times when the computer was asleep. The "5" could also be "10" for every ten minutes. Or whatever you decide you'd like.
I'd show you an AppleScript, but I'm really not so good at that. If a Perl script would help, I could whip one up pretty quickly, I think.
charlie
Maybe you are looking for
-
Starting exetutable java file from java code
Hi I was wondering how I can start a executable java file from java code? thanks
-
How do you create a section in labview using the configurat​ion file vis
I'm trying to create a new section in Labview. All i see is the possibilties to read sections and keys, write keys, delete sections. Is there a way to write a new section in Labview. Thanks, Brandon Solved! Go to Solution.
-
Macbook Air Or Pro For University.
I was just wondering which laptop would be better for university. I love the macbook air and how it is so light and portable, but in saying that, I keep thinking that a macbook pro would be better as it has more GHZ. I plan to do a Bachalor Of Busine
-
Problem Moving XCode Project From iMac to MacBook
I have been working with an Objective C library for iPhone apps using XCode on a iMac running OS X Lion 10.7.5 (11G63). My project builds fine on this system. I need to relocate the project to a MacBook Pro running OS X 10.8.4 (12E55). I have XCode 4
-
How to avoid "The local variable ___ is never read" warnings
If you create an instance of a class using something like: MyClass myClassInstance = new MyClass(param1, param2, ...); And everything you require this class to do is done from within it's constructor then you always get a warning saying "The local va