LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   cron help (https://www.linuxquestions.org/questions/linux-software-2/cron-help-450317/)

gazman1 05-31-2006 03:35 PM

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.

acid_kewpie 05-31-2006 03:48 PM

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...

gazman1 05-31-2006 03:54 PM

i didn't it was someone else, who is not around so any ideas?

dive 05-31-2006 03:57 PM

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/

gazman1 05-31-2006 04:02 PM

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

homey 05-31-2006 06:02 PM

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.

dive 05-31-2006 06:22 PM

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)?


All times are GMT -5. The time now is 07:16 AM.