Home Man
Search
Today's Posts
Register

Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

crontab issue

Tags
advanced

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 03-22-2009
crontab issue

I am adding a piece of code which adds entry in crontab ((in brown color))


\crontab -l > $tmpfile
echo "Removing the cleanProcess entry if it already existed.."
grep -v "cleanProcess.sh" $tmpfile > $newtmpfile
lcnt=`grep -c "cleanProcess.sh" $tmpfile`
echo "Number of entries in cron is : $lcnt"
if [ $lcnt -eq 0 ]; then
echo "Entry didn't exist before. Adding new...."
echo "\n" >> $newtmpfile
else
echo "Entry already existed. Replacing it..."
fi
echo "0,5,10,15,20,25,30,35,40,45,50,55 * * * * $/test/bin/cleanProcess.sh" >> $newtmpfile
crontab $newtmpfile
echo "Added the new entry.."



crontab is empty ==>

$> crontab -l
$>


but file is having string as follows :

\n
echo "0,5,10,15,20,25,30,35,40,45,50,55 * * * * $/test/bin/cleanProcess.sh"


becoz of that the crontab is not able to initialized properly .

any anybody help me out whats wrong with it?

Last edited by crackthehit007; 03-22-2009 at 10:21 AM..
# 2  
Old 03-22-2009
Solaris cron does not like empty lines and will not work that way as you have discovered, so your line:
Code:
echo "\n" >> $newtmpfile

needs to be:
Code:
echo "#\n" >> $newtmpfile

instead.
# 3  
Old 03-22-2009
my system is linux redhat.
and now entry in crontab is

$> crontab -l
#\n
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /test/bin/cleanProcess.sh




is that #\n is valid entry in crontab?

Last edited by crackthehit007; 03-22-2009 at 10:30 AM..
# 4  
Old 03-22-2009
More valid than an empty line or a "\n", the crontab will now work, I see the \n is being treated literally, should have said:
Code:
echo "#" >> $newtmpfile

The \n is quite unnecessary! Should have realised that before, doh!
# 5  
Old 03-22-2009
Thanks a lot..
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Another issue with crontab rafa_fed2 Shell Programming and Scripting 30 07-24-2013 08:08 PM
Crontab issue jrymer UNIX for Dummies Questions & Answers 6 06-30-2013 04:51 PM
Crontab Issue aravindj80 UNIX for Advanced & Expert Users 10 05-30-2013 02:21 PM
Crontab Issue..!!! gayisada UNIX for Dummies Questions & Answers 1 05-02-2011 05:55 AM
Crontab issue h@foorsa.biz AIX 3 05-02-2011 03:55 AM
Crontab issue pinga123 UNIX for Advanced & Expert Users 1 03-17-2011 05:22 AM
Issue with crontab Sriranga Shell Programming and Scripting 12 06-24-2010 09:19 AM
crontab issue mac4rfree Shell Programming and Scripting 2 06-30-2009 05:51 AM
Crontab Issue rickyt00 UNIX for Dummies Questions & Answers 2 08-06-2005 09:31 AM
crontab issue Semper_Tempus Solaris 6 07-19-2005 10:13 PM


All times are GMT -4. The time now is 09:07 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password