I have one cron job installed but not running. I installed it with crontab -e
and entered the following.
0 12 * * * /var/www/drupal/scripts/dump_sites
* * * * * wall /tmp/test
I put the second command for testing purposes. There is indeed a file /tmp/test, it simply has "this is a test" in it.
When I exit crontab -e
I receive no error messages. There are no log files for cron in /var/log/
. I stopped cron with service cron stop
and tried starting it with cron -L 2
to get better debug output, but there are still no logs.
I've ran /var/www/drupal/scripts/dump_sites
manually and I get the expected behavior, i.e. output files appear where I want them to. When I try with cron, I do not get the expected behavior.
When I do ps aux | grep cron
I can see it with an associated process ID.
I gave up on cron momentarily and tried anacron. ps aux | grep cron
now yields the following. However; my dump_sites
script still doesn't run.
devcampus :: /var/www/drupal » ps aux | grep cron
root 15635 0.0 0.1 12440 928 ? Ss 11:59 0:00 anacron -f
root 15816 0.0 0.1 4092 608 ? S 12:04 0:00 /bin/sh -c nice run-parts --report /etc/cron.daily
root 15818 0.0 0.1 3996 620 ? SN 12:04 0:00 run-parts --report /etc/cron.daily
root 15825 0.0 0.1 4092 680 ? SN 12:04 0:00 /bin/sh /etc/cron.daily/apt
My /etc/anacrontab
file looks like this.
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# These replace cron's entries
1 5 cron.daily nice run-parts --report /etc/cron.daily
7 10 cron.weekly nice run-parts --report /etc/cron.weekly
@monthly 15 cron.monthly nice run-parts --report /etc/cron.monthly
# period delay job-identifier command
@daily 14 backup /var/www/drupal/scripts/dump_sites
I'm running Ubuntu 10.04, and I believe this box is running on a Xen virtualization server.
devcampus :: /var/www/drup
2.6.32-23-server
Update: apparently it's working with anacron.
As per request, here's dump_sites
:
#!/usr/bin/env ruby
DRUPAL_ROOT = File.expand_path(File.dirname(__FILE__) + '/../')
SITES_ROOT = File.join(DRUPAL_ROOT, 'sites')
CONFIG_FILES = Dir.glob(File.join(SITES_ROOT, "*", "dbconfig.php"))
databases = CONFIG_FILES.map do |cf|
contents = File.read(cf)
contents =~ /dbname='(.*)'/ ? $1 : nil
end
databases.uniq!
databases.sort!
databases.each do |db|
file_name = File.join(DRUPAL_ROOT, "db_dumps", "#{db}_#{Time.now.strftime("%Y-%m-%d-%H-%M-%S")}.sql")
`mysqldump -uusername -ppassword #{db} > #{file_name}`
end
Just a plain old ruby script.
mysqldump
or something.wall
work fromcron
?