Open Source Training Seminar FreePBX Paid Support

Ticket #2861 (closed Bugs: worksforme)

Opened 2 months ago

Last modified 2 months ago

backup module clears crontab for user "asterisk"

Reported by: imcdona Assigned to:
Priority: minor Milestone: 2.5
Component: Backup & Restore Version: 2.4-branch
Keywords: cron backup crontab Cc:
Confirmation: Need Feedback SVN Revision (if applicable):
Backend Engine: Asterisk 1.4.x Backend Engine Version:

Description (Last modified by p_lindheimer)

Creating a backup schedule via the backup module clears any existing cron jobs for user "asterisk".

Steps to reproduce:

  1. create a cronjob that runs as user "asterisk"
  2. run "crontab -u asterisk -l" to list user asterisk's crontab and verify there is indeed data in the crontab
  3. Schedule a backup via the FreePBX
  4. Run "crontab -u asterisk -l" again and you will see that all entries are removed and the only entry is the backup job.

Change History

06/23/08 20:34:49 changed by p_lindheimer

  • confirmation changed from Unreviewed to Need Feedback.
  • description changed.
  • milestone changed from Cut Line to 3.0.

You will have to be much more specific or we'll have to close this worksforme. The backup job only clears it's own entries and leaves other cron jobs owned by asterisk in place.

Here is the code that does it:

First Create the list of backup jobs to be added to cron:

foreach my $row ( @{ $result } ) {                                                                                                             
  my $Backup_Command = @{ $row }[0];                                                                                                           
  my $Backup_ID = @{ $row }[1];                                                                                                                
  print EXTEN "$Backup_Command $Backup_ID\n";                                                                                                  
}                                                                                                                                              

Now look for all other asterisk cron jobs not related to backup:

  #grab any other cronjobs that are running as asterisk and NOT associated with backups                                                        
  system ("/usr/bin/crontab -l | grep -v ^#\ DO\ NOT | grep -v ^#\ \( |  grep -v ampbackup.pl  >> $Backup_cron ");                             
  #issue the schedule to the cron scheduler                                                                                                    
  system ("/usr/bin/crontab $Backup_cron");                                                                                                    

And FreePBX itself has another cron job not related with backup that runs fine. So as you can see, you'll need to give exact repro steps with the exact crontab entry you made that creates your problem.

06/24/08 23:05:03 changed by imcdona

Looking at the command "/usr/bin/crontab -l | grep -v #\ DO\ NOT | grep -v #\ \( | grep -v ampbackup.pl" I noticed that the crontab command does not have the "-u" flag to specify the user. Could this be the issue? Or does the command run as user asterisk so it defaults to that users crontab. When I run it manually with the "-u asterisk" I get a list of my cronjobs NOT related to asterisk. When I run the command above WITHOUT the "-u" flag I get:

31 15 * * * /etc/webmin/cron/tempdelete.pl @daily /etc/webmin/backup-config/backup.pl 120738273729015

When I run the command WITH the "-u asterisk" I get the entries not related to backups:

* * * * * cd /var/www/html/cti; php -f cron.php > /dev/null 2>&1 * * * * * cd /var/www/html/sugar; php -f cron.php > /dev/null 2>&1

Here is my full crontab for asterisk by running "crontab -l -u asterisk":

0 0 * * * /var/lib/asterisk/bin/ampbackup.pl 2 * * * * * cd /var/www/html/cti; php -f cron.php > /dev/null 2>&1 * * * * * cd /var/www/html/sugar; php -f cron.php > /dev/null 2>&1

When I add a backup schedule I lose the last two entries:

* * * * * cd /var/www/html/cti; php -f cron.php > /dev/null 2>&1 * * * * * cd /var/www/html/sugar; php -f cron.php > /dev/null 2>&1

Also, I created the last two cron entries via webmin. I dont think that would be an issue but I thought I would let you know just in case.

Thanks in advance

06/25/08 00:23:50 changed by p_lindheimer

it should be run as user asterisk, currently FreePBX expects apache to be running as user asterisk.

06/25/08 21:53:03 changed by imcdona

From

httpd.conf

User asterisk
Group asterisk

ps shows httpd running as asterisk as well. Is there something else you want me to run on my system to troubleshoot?

06/25/08 22:54:29 changed by p_lindheimer

I'm not sure what is going on with your system. Do the following:

  1. Enable Check for updates in the General Tab (so we can see that cron job).
  2. Paste the output of 'crontab -l -u asterisk' and 'ps -ef | grep asterisk'
  3. Create the backup set
  4. Paste the output of 'crontab -l -u asterisk' again

06/26/08 18:07:04 changed by imcdona

1. Updates were already enabled. I disabled and re-enabled them and don't see any additional cron jobs. I also deleted the backup schedule and enabled/re-enabled updates and still don't see the update cron job.

crontab -l -u asterisk
* * * * *  cd /var/www/html/cti; php -f cron.php > /dev/null 2>&1
* * * * * cd /var/www/html/sugar; php -f cron.php > /dev/null 2>&1
ps -ef | grep asterisk

root       937     1  0 Jun25 ?        00:00:00 /bin/bash /usr/sbin/safe_asterisk -U asterisk -G asterisk
asterisk   948   937  0 Jun25 ?        00:05:24 /usr/sbin/asterisk -f -U asterisk -G asterisk -vvvg -c
root       988 15151  0 Jun22 pts/1    00:00:00 rasterisk r
asterisk  1018     1  0 Jun25 ?        00:00:00 -bash -c cd /var/www/html/panel && /var/www/html/panel/safe_opserver &
asterisk  1019  1018  0 Jun25 ?        00:00:00 sh /var/www/html/panel/safe_opserver
asterisk  4362  4360  0 Jun22 ?        00:02:32 /usr/sbin/httpd
asterisk  4363  4360  0 Jun22 ?        00:02:17 /usr/sbin/httpd
asterisk  4364  4360  0 Jun22 ?        00:02:51 /usr/sbin/httpd
asterisk  4365  4360  0 Jun22 ?        00:02:44 /usr/sbin/httpd
asterisk  4366  4360  0 Jun22 ?        00:02:39 /usr/sbin/httpd
asterisk  4367  4360  0 Jun22 ?        00:02:17 /usr/sbin/httpd
asterisk  4368  4360  0 Jun22 ?        00:02:44 /usr/sbin/httpd
asterisk  4369  4360  0 Jun22 ?        00:02:29 /usr/sbin/httpd
asterisk  6801  4360  0 Jun22 ?        00:02:10 /usr/sbin/httpd
asterisk 10798  4360  0 Jun22 ?        00:01:08 /usr/sbin/httpd
asterisk 27230  4360  0 Jun23 ?        00:00:47 /usr/sbin/httpd
asterisk 31793  1019  0 17:57 ?        00:00:02 /usr/bin/perl -w /var/www/html/panel/op_server.pl
root     32471 15151  0 18:04 pts/1    00:00:00 grep asterisk

3. Created backup set

4. output of 'crontab -l -u asterisk'

0 0 1 1 * /var/lib/asterisk/bin/ampbackup.pl 5

This doesn't make any sense?!?!?!

07/04/08 15:27:41 changed by p_lindheimer

  • status changed from new to closed.
  • resolution set to worksforme.

I'm closing this as worksforme, there is something really odd on your system.

07/08/08 07:45:45 changed by p_lindheimer

imcdona

have a look at r5963, any chance that does anything to help your situation?

Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads