LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-31-2006, 03:35 PM   #1
gazman1
Member
 
Registered: Jan 2005
Posts: 40

Rep: Reputation: 15
cron help


Ok I have a cron backup running every day at 12 but when I type crontab -l it says I have no crons schedulded so how do i view what crons are running and modify them? it is def running at 12 everyday.
 
Old 05-31-2006, 03:48 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
crontab -l will list the current users cron jobs. if you have added to /etc/crontab or the common subdirectory structure in /etc/ then these will not show up. how did you configure this job in the first place? to change it just do the same again...
 
Old 05-31-2006, 03:54 PM   #3
gazman1
Member
 
Registered: Jan 2005
Posts: 40

Original Poster
Rep: Reputation: 15
i didn't it was someone else, who is not around so any ideas?
 
Old 05-31-2006, 03:57 PM   #4
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
crontab -e will put you in edit mode so you can see what jobs are there and make changes etc

Do you know which user the job is running under? If it's root doing the above command as root will show up root's jobs

You might also want to look at /etc/cron.* dirs ie

cron.daily/ cron.hourly/ cron.monthly/ cron.weekly/

Last edited by dive; 05-31-2006 at 04:01 PM.
 
Old 05-31-2006, 04:02 PM   #5
gazman1
Member
 
Registered: Jan 2005
Posts: 40

Original Poster
Rep: Reputation: 15
I've no idea I tried both crontab -l for both the a/c the guy who set it up had and as root and it said both times that there was no crontab set up
 
Old 05-31-2006, 06:02 PM   #6
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Setting up a cron job as user fred

First, I'll set up a little diddy to test my script and make sure crontab is working.
For quick testing, I tell cron to run it every minute and that will be changed for my real backup cron.

For example:
Code:
#!/bin/bash

filename=`date '+%H%M'`
ls /home/images > ~/$filename.txt
Next, I make the script executeable
chmod +x /home/fred/backup.job

I use the vi editor
export EDITOR=vi

Use this command to set the crontab file as being /etc/crontab
crontab /etc/crontab

Edit the crontab to include your script. You could also put the script in one of the /etc/cron folders

crontab -e
Code:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

* * * * * /home/fred/backup.job

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
You need to restart the crond service as root user
Code:
su - -c "service crond restart"
After you have that working properly, you could change the backup script to something more usefull.
For example:
Code:
#!/bin/bash
filename=`date '+%m%d%y'`
cd /home/images
/bin/tar -cvzf /mnt/backup/${filename}.tar.gz . \
> /mnt/backup/${filename}.log \
2> /mnt/backup/${filename}err.log
And the cron could be a reasonable once a day setting.
Add a line to your personal crontab.....
00 23 * * * /mnt/backup/backup.job

Don't forget that root needs to restart the crond.
 
Old 05-31-2006, 06:22 PM   #7
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
Quote:
Originally Posted by gazman1
I've no idea I tried both crontab -l for both the a/c the guy who set it up had and as root and it said both times that there was no crontab set up
Did you look in /etc/cron.daily (might be different on your sys)?
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
cron.allow and cron.deny in slackware? tl64 Slackware 5 10-13-2005 09:44 PM
No More Cron Mail, Cron Error? Xhost Linux - General 3 07-26-2004 04:28 PM
[cron][mdk9.1]cron deamon seems to ignore some task... yannrichet Linux - Newbie 5 06-26-2003 09:57 AM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 02:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:38 AM.

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