tablecleaner command forces a double prompt

corey34

Active Member
I'm trying to run the tablecleaner command with a cron but the command forces a double prompt before deleting records. Is there a way to stop the double prompt so I can have this run on it's own?

Here's the command with the prompt's and output:

>/bin/php -q /home/.../public_html/apps/console/console.php table-cleaner --table=mw_campaign_url --time="-2 month"
Are you sure you want to delete the records from the "mw_campaign_url" table that are older than "2017-04-30 21:29:25" date? (yes|no) [no]:y
This action will delete 17688537 records from the "mw_campaign_url" table. Proceed? (yes|no) [no]:y
DONE, took 1152.8297 seconds!
 
Ah, gotcha. Then duplicate the command, give it a new name and remove the prompt statements, that's your best bet which is also safe for upgrades.
 
@corey34 -
1. Duplicate the file, name it MyTableCleanerCommand.php
2. Open it and rename the class to, from class TableCleanerCommand to class MyTableCleanerCommand
3. Remove the prompt commands.
4. Call the command like: php -q /path/to/apps/console/console.php mytablecleaner
 
The only file I could find with that class is TableCleanerCommand.php located at /apps/console/commands/. I followed the rest of the steps but when I run the console command I get the usage text returned, as if I've entered a command that doesn't exist. Is that the wrong file I am editing?

Thanks
 
The only file I could find with that class is TableCleanerCommand.php located at /apps/console/commands/. I followed the rest of the steps but when I run the console command I get the usage text returned, as if I've entered a command that doesn't exist. Is that the wrong file I am editing?

Thanks
Can you pls write out the details of what you did?
Did you indeed edit the (TableCleanerCommand.php copied into) 'MyTableCleanerCommand.php' to get rid of the prompts and then use 'console MyTableCleaner'?
 
Here's what I did:

cd /home/..../public_html/apps/console/commands
cp TableCleanerCommand.php TableCleanerCommandNoPrompt.php
vi TableCleanerCommandNoPrompt.php (to remove prompts and change "class TableCleanerCommand" to "class TableCleanerCommandNoPrompt"
/bin/php -q /home/...../public_html/apps/console/console.php TableCleanerNoPrompt --table=mw_campaign_url --time="-2 month"

The result is:
Yii command runner (based on Yii v1.1.17)
Usage: /home/..../public_html/apps/console/console.php <command-name> [parameters...]

The following commands are available:
- archive-campaigns-delivery-logs
- archivecampaignsdeliverylogs
.... (etc.)
 
Here's what I did:

cd /home/..../public_html/apps/console/commands
cp TableCleanerCommand.php TableCleanerCommandNoPrompt.php
vi TableCleanerCommandNoPrompt.php (to remove prompts and change "class TableCleanerCommand" to "class TableCleanerCommandNoPrompt"
/bin/php -q /home/...../public_html/apps/console/console.php TableCleanerNoPrompt --table=mw_campaign_url --time="-2 month"

The result is:
Yii command runner (based on Yii v1.1.17)
Usage: /home/..../public_html/apps/console/console.php <command-name> [parameters...]

The following commands are available:
- archive-campaigns-delivery-logs
- archivecampaignsdeliverylogs
.... (etc.)
It did not work because the structure needs to be
.../xyzCOMMAND.php
.../apps/console/console.php xyz
;)
 
Thanks @frm.mwz, although I'm not sure what you mean by this.
You have:
.../TableCleanerCommandNoPrompt.php
.../apps/console/console.php TableCleanerNoPrompt
but it needs to be:
.../TableCleanerNoPromptCommand.php
.../apps/console/console.php TableCleanerNoPrompt
ie the string "COMMAND" needs to be at the END of the command file name (in order for the console to find/execute it).
;)
 
Back
Top