LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 09-15-2006, 06:36 AM   #1
bujecas
Member
 
Registered: Oct 2004
Location: Portugal
Distribution: Debian, Slackware
Posts: 78

Rep: Reputation: 15
user crontab


Hello,

I want to add a line to the user crontab automatically without interaction. That means, I don't want to use crontab -e -u <user>. I'm trying to user the "crontab -l |crontab -" but I don't know how to put the news lines of cronjobs.

Any help?
 
Old 09-15-2006, 06:49 AM   #2
ckeswani
LQ Newbie
 
Registered: Sep 2005
Posts: 10

Rep: Reputation: 0
I use sed to edit my crontab. In the example below, I have a bash function that takes args in the format of <day> hour:minute and replaces the corresponding entry in the crontab.
function setAlarm
CRONFILE=~/cronjobs/crontab.out;
crontab -l >$CRONFILE;
DAY=$1;
HOUR=`echo $2 | awk -F: '{print $1}';`;
MINUTE=`echo $2 | awk -F: '{print $2}';`;
if [ -z "$DAY" ] || [ -z "$HOUR" ] || [ -z "$MINUTE" ]; then
echo "Usage: setAlarm {day} {hour:minute}";
return;
fi;
sed -i.bak -e "/.*${DAY}.*morningPlaylist/s/[0-9][0-9][ \t]*[0-9][0-9]/${MINUTE} ${HOUR}/" $CRONFILE;
crontab $CRONFILE;
crontab -l
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
crontab --u user file binary_0011 Linux - Newbie 2 05-06-2006 06:14 AM
Crontab not working for user mago Slackware 5 04-03-2006 10:48 PM
problems setting the user in crontab p.gaic Linux - Software 1 07-15-2005 12:07 AM
Crontab "root user" problems... Clubber Lang Linux - General 3 09-30-2004 10:29 AM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 01:35 PM


All times are GMT -5. The time now is 12:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration