UNIX for Advanced & Expert Users

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

👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-22-2009
crackthehit007 crackthehit007 is offline
Registered User
 
Join Date: Feb 2009
Last Activity: 2 June 2010, 4:06 AM EDT
Location: Pune/Banagalore
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
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..
Sponsored Links
    #2  
Old 03-22-2009
TonyFullerMalv's Unix or Linux Image
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 1 July 2013, 6:45 PM EDT
Location: Malvern, Worcs. U.K.
Posts: 1,033
Thanks: 0
Thanked 8 Times in 8 Posts
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.
Sponsored Links
    #3  
Old 03-22-2009
crackthehit007 crackthehit007 is offline
Registered User
 
Join Date: Feb 2009
Last Activity: 2 June 2010, 4:06 AM EDT
Location: Pune/Banagalore
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
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
TonyFullerMalv's Unix or Linux Image
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 1 July 2013, 6:45 PM EDT
Location: Malvern, Worcs. U.K.
Posts: 1,033
Thanks: 0
Thanked 8 Times in 8 Posts
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!
Sponsored Links
    #5  
Old 03-22-2009
crackthehit007 crackthehit007 is offline
Registered User
 
Join Date: Feb 2009
Last Activity: 2 June 2010, 4:06 AM EDT
Location: Pune/Banagalore
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks a lot..
Sponsored Links
👤 Login to reply

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
Crontab email issue ryannam Solaris 5 06-20-2008 12:39 PM
Weird Issue with crontab. Cameron HP-UX 3 04-21-2008 11:36 PM
crontab issue vaddi HP-UX 11 01-28-2008 05:07 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 07:10 PM.

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





Not a Forum Member?
Forgot Password?