LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 10-12-2011, 01:58 PM   #1
rfrusher
LQ Newbie
 
Registered: Oct 2011
Location: Texas
Posts: 14

Rep: Reputation: Disabled
Cron scheduler


Hello everyone,
My name is Ron
I have been taking some classes on linux.
I am looking for some guidance. I have downloaded SUSE. I wrote a script that I want scheduled. I am trying to figure out how to put it in the crontab.
I see everyone saying crontab -e as the editor.
Not sure if that where to put it and how accomplish this.
thanks
 
Old 10-12-2011, 02:18 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Hi Ron and welcome to LinuxQuestions!

Yes, the command crontab -e is the right way to go, since it lets you set your personal user's crontab. The crontab -e command opens a vi session where you can type your cron job specifications. If you're not used to the vi editor, you can choose any other text editor by setting the EDITOR environment variable, e.g.
Code:
export EDITOR=kwrite
When you save the document the crontab is set and you can see it using crontab -l. To completely remove your crontab you need the option -r. That's it. Try to write down your cron job and feel free to ask for any doubt.
 
Old 10-16-2011, 10:39 AM   #3
rfrusher
LQ Newbie
 
Registered: Oct 2011
Location: Texas
Posts: 14

Original Poster
Rep: Reputation: Disabled
I remove the crontab

I wrote a script and I wanted to delete the script. So I problably did something dumb. Better to do it here on my personal computer that at a business.
I ran crontab -r thinking it would let me remover just the script I wrote. Now when I run crontab -l is say "absolute path to 'cron is' /usr/sbin/cron. so running it requires super user priveledges. Before I did the cron -r, it pulled up the crontab no problem. Is there a way to put it back?
 
Old 10-16-2011, 10:46 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by rfrusher View Post
I wrote a script and I wanted to delete the script.
Remove a script or a crontab entry? If you want to remove a script you need the rm command, to remove a crontab entry just do crontab -e to edit your current crontab.
Quote:
Originally Posted by rfrusher View Post
I ran crontab -r thinking it would let me remover just the script I wrote. Now when I run crontab -l is say "absolute path to 'cron is' /usr/sbin/cron. so running it requires super user priveledges. Before I did the cron -r, it pulled up the crontab no problem. Is there a way to put it back?
Given the error you got, maybe you typed cron -l not crontab -l !!
 
1 members found this post helpful.
Old 10-16-2011, 11:03 AM   #5
rfrusher
LQ Newbie
 
Registered: Oct 2011
Location: Texas
Posts: 14

Original Poster
Rep: Reputation: Disabled
no crontab

Now when I run crontab -l , it reports that there is not crontab for my username???
 
Old 10-16-2011, 11:05 AM   #6
rfrusher
LQ Newbie
 
Registered: Oct 2011
Location: Texas
Posts: 14

Original Poster
Rep: Reputation: Disabled
crontab

It's kinda wierd that I show no crontab for my user when I run I run this command in SU, it says that I have no crontab for root?
 
Old 10-16-2011, 11:47 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
It's not clear what you actually did. Anyway, root and normal users have different crontab. In any case you can edit your crontab again using crontab -e.

Then I suggest to keep a backup of your crontab once you have created it (especially if there are multiple entries or if the command line is not easy to remember). You can do
Code:
crontab -l > $HOME/crontab.backup
If you remove it by mistake, then you can restore it by simply doing:
Code:
crontab $HOME/crontab.backup
that is the crontab in this case is taken from the content of the backup file. Please, read carefully the man page of crontab to see the different syntax and options available to manage the crontab.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Using cron scheduler on Linux systems LXer Syndicated Linux News 0 09-29-2011 02:30 AM
LXer: Scheduling Tasks using Gnome-Scheduler, a GUI for Cron and At LXer Syndicated Linux News 0 08-03-2010 09:30 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 01:57 AM
Slackware's Cron Scheduler: I'm thinking maybe I need to put in a different cron? Old_Fogie Slackware 5 11-03-2006 06:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 08:29 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
Open Source Consulting | Domain Registration