These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for Accidentally deleted all cron jobs - is there a way to bring them all back? on the new forum.
Using a program that was meant to append a cron, but seems to have deleted everything.
Here's what I've got at the moment (see link below), are any Virtualmin/webmin ones missing?
http://i66.tinypic.com/j8pt9k.png
Is there an easy way to get my old cron jobs back?
Ok, I've found all the cron jobs that run yesterday in
/var/log/cron
and have added all of my own cron jobs back in.I've also added this one:
/etc/webmin/status/monitor.pl
But am unsure of these entries:
Feb 27 00:01:01 rock CROND[3042]: (root) CMD (run-parts /etc/cron.hourly)
Feb 27 03:25:01 rock run-parts(/etc/cron.daily)[25731]: starting logrotate
Feb 27 03:25:04 rock run-parts(/etc/cron.daily)[27038]: finished man-db.cron
Feb 27 03:25:04 rock run-parts(/etc/cron.daily)[25731]: starting locate
Do I need to add them too? (How?)
Does anyone know what the default webmin/virtualmin cron jobs are please?
Howdy,
Just to clarify, are you saying you lost all of root's cronjobs? Or the cron jobs for a particular user?
-Eric
Hi Eric
I ran the command as root so I am guessing it deleted all of them - the only ones remaining were the ones in this image:
http://i66.tinypic.com/j8pt9k.png
I have since deactivated the trio as I don't use awstats and the spamassasin and clamav ones, but have manually added the follow two:
/etc/webmin/status/monitor.pl (3 times an hour)
/etc/cron.hourly/0anacron (hourly - should that 0 be in there?)
And left these there:
/usr/sbin/csf -u (once a day)
/usr/sbin/raid-check (once a day)
/etc/init.d/lfd restart > /dev/null 2>&1 (once a day)
Am I missing any others?
Howdy,
Hmm, did it just remove the cron jobs in root's crontab, which can be seen by running "crontab -l"? Or did it also remove everything in "/etc/cron.hourly", "/etc/cron.daily", "/etc/cron.weekly", and "/etc/cron.monthly"?
I think you got the main Virtualmin cron jobs, but my concern is that other system tasks may have been removed.
-Eric
Thanks Eric, here is the output and contents of that command/directories:
# crontab -l
# Begin Whenever generated tasks for: /home/mysite.com/app/releases/3535/config/schedule.rb
# 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c (cron job details here)
# End Whenever generated tasks for: /home/mysite.com/app/releases/3535/config/schedule.rb
@hourly /opt/rubies/ruby-2.2.2/bin/ruby (my-cron-2)
30 15 * * * /opt/rubies/ruby-2.2.2/bin/ruby (my-cron-3)
55 3 * * * /opt/rubies/ruby-2.2.2/bin/ruby (my-cron-4)
4 10 * * * /opt/rubies/ruby-2.2.2/bin/ruby (my-cron-5)
30 10 * * * /opt/rubies/ruby-2.2.2/bin/ruby (my-cron-6)
1,17,31,47 * * * * /etc/webmin/status/monitor.pl
@hourly /etc/cron.hourly/0anacron
# cd /etc/cron.hourly
# ll
total 28
drwxr-xr-x. 2 root root 4096 Feb 26 01:57 ./
drwxr-xr-x. 104 root root 12288 Feb 29 22:34 ../
-rwxr-xr-x 1 root root 392 Jul 27 2015 0anacron*
-rwxr-xr-x 1 root root 362 Dec 3 15:33 0yum-hourly.cron*
-rwxr-x--- 1 root root 174 Jul 27 2015 awstats*
# cd /etc/cron.daily
# ll
total 36
drwxr-xr-x. 2 root root 4096 Feb 26 01:57 ./
drwxr-xr-x. 104 root root 12288 Feb 29 22:34 ../
-rwxr-xr-x 1 root root 211 Jan 4 2013 00webalizer*
-rwxr-xr-x 1 root root 332 Dec 3 15:33 0yum-daily.cron*
-rwx------ 1 root root 180 Jul 31 2013 logrotate*
-rwxr-xr-x. 1 root root 618 Mar 17 2014 man-db.cron*
-rwxr-x--- 1 root root 192 Jan 26 2014 mlocate*
# cd /etc/cron.weekly
# ll
total 16
drwxr-xr-x. 2 root root 4096 Jun 9 2014 ./
drwxr-xr-x. 104 root root 12288 Feb 29 22:34 ../
# cd /etc/cron.monthly
# ll
total 16
drwxr-xr-x. 2 root root 4096 Jun 9 2014 ./
drwxr-xr-x. 104 root root 12288 Feb 29 22:34 ../
Does that all look ok?
Also, I don't use awstats or webalizer, neither are 'on' in Webmin > cron jobs, but do I need to remove them from the daily and hourly directories too?
Edit: looking at it now looks like I need to add the following as daily crons?
logrotate* man-db.cron* mlocate*
I know that logrotate is needed, but not sure about man-db and mlocate?
Howdy,
Hmm, you seem to be missing a variety of cron jobs.
My suggestion would be to setup another server using the same distro/version, and to grab missing files from it.
You may also want to double-check /etc/crontab, and /etc/cron.d.
-Eric
Can you think of any that are not showing Eric? I usually go with the Centos 'minimal' install - could that be a factor?
Here is the output of the command and contents of the dir:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
# cd /etc/cron.d
# ll
total 48
drwxr-xr-x. 2 root root 4096 Mar 3 00:43 ./
drwxr-xr-x. 104 root root 12288 Mar 4 11:35 ../
-rw-r--r-- 1 root root 129 Feb 28 02:00 0hourly
-rw------- 1 root root 220 Feb 28 02:00 clamav-update
-rw-r--r-- 1 root root 14 Feb 1 2013 csf-cron
-rw------- 1 root root 48 Feb 27 15:21 csf_update
-rw-r--r-- 1 root root 70 Feb 1 2013 lfd-cron
-rw-r--r-- 1 root root 132 Jul 27 2015 mailman
-rw-r--r-- 1 root root 108 Sep 18 16:07 raid-check
-rw-r--r-- 1 root root 461 Mar 1 18:13 sa-update