Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


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

Rep: Reputation: 20
user crontab


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, 05:49 AM   #2
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
crontab -l >$CRONFILE;
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}";
sed -i.bak -e "/.*${DAY}.*morningPlaylist/s/[0-9][0-9][ \t]*[0-9][0-9]/${MINUTE} ${HOUR}/" $CRONFILE;
crontab $CRONFILE;
crontab -l


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 05:14 AM
Crontab not working for user mago Slackware 5 04-03-2006 09:48 PM
problems setting the user in crontab p.gaic Linux - Software 1 07-14-2005 11:07 PM
Crontab "root user" problems... Clubber Lang Linux - General 3 09-30-2004 09:29 AM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:10 PM.

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