Commands for Cron Jobs

I got totally lost the other day when I couldn’t get a cron job to work. Now, what path was that?

WordPress Database Backup is a plugin that I’d relied on in the past to keep a randomly backed up copy of a WordPress site. Unfortunately, that’s not a complete solution as the images or uploads folder, as well as any modified theme pages, won’t be saved during the database backup. Nor will the blog links! Keep an archive copy of everything you put on your website, so everything can be reconstructed in the case of a disaster or even a host switch. In case a website is made up of more than one database, you’d need a different backup solution than what a WordPress plugin can provide.

Use CRON jobs to automate the task of backing up all your hard work. It might take a while to figure things out, but once you do you’ll be secure in the knowledge that you did it and your data is safe.

At first I didn’t have the command part right for the cron job to work. After the time elements you need to indicate the path to sh, any flags (none used here), and the path to the shell script. In this case the command was –

/bin/sh /home/owner/backup/automysqlbackup.sh

where “owner” is the CPanel login name, and “backup” is an empty directory or folder that you create above the public_html directory. Some hosts will have a folder called “etc” already created for you. Check with your host!

In this case the /bin/sh directory was already created at the server level, in other words, I didn’t have to create it. The corresponding first line in the .sh file was –

#!/bin/sh

Originally, the .sh file had an opening #!/bin/bash, but that didn’t work on this particular host.

The host tells me the script is running successfully, so I know the lack of output is my fault – somewhere. Checks the paths…found it! An error in the path for the configuration file lead to the script trying to run with default parameters, some of them blank. The script ran as far as it could so there was no error reported by the cron daemon to my email address. When the output is successful a log file is sent to that address.

When I finally got the paths straightened out, the backup files were zipped and in their proper places and an email log was sent to the proper address at the time the cron job was to run. It worked! Now I’ll go back and set up a couple of other cron jobs to back up other databases. I’ll use the same script, modified to back up different sets of databases on different schedules.

  • If you’re looking for a simple script to make one database backup and save that on your server, check out DaniWeb’s CRON job for backup.

Once you have your sites backed up automatically, you can do away with any backup plugins that you may have relied on in the past. When at all possible, automate the task of backing up a database. It’ll make your life easier!

WordPress 3.0 Worth the Upgrade

Hey Guys!

WordPress 3.0 is here and it’s definitely worth the download. The time you could save in keeping your blogging software up-to-date alone by using WP 3.0 is worth the upgrade. When it comes time to update the WordPress software, including plugins, all it takes is one click!

I love the new Twenty Ten theme for its wider view and its modern look and feel. It’s easy to modify, too.

Just take a look at this video for a quick lesson about WordPress 3.0 –

Mass Delete Spam Comments in WordPress

So, the spam is getting out of control on your WordPress blog? Even if you have activated the Akismet plugin – and you should – SPAM may keep filing up the comments.

You can just let it ride and those comments identified by Akismet as spam will silently disappear in a month’s time. In the meantime your database will be getting bigger and bloated with thousands of lines of useless information. Will this bog down your blog? Perhaps it will.

I found another reason to manually delete all the spam comments on one of my WP blogs. From the WP Dashboard I saw 1000+ spam comments and went to edit the comments. When I clicked on ‘spam’, the anti-virus software on this computer, AVG, detected a threat on the spam comments page and blocked my access to it. Even after shutting down the browser and returning to the edit spam comments page another day, the AVG software wouldn’t let me in. How could I delete the spam if I can’t get to the page to do it? Even if I could get to that page it would take a long time to delete so many comments. There must be a better solution to getting rid of spam comments in WordPress.

So, how do you mass delete spam comments in WordPress? Check out this excellent video that provides a solution using phpmyadmin and your WordPress blog database.

Steps to follow:

  1. sign in to CPanel
  2. open up phpmyadmin and select the WP database
  3. click on “wp_comments” table and browse to see the comments
  4. backup database by clicking on database name in left column, click on export tab, select all tables under Export, select SQL, check “save as file”, click Go to download database backup to your computer
  5. select comments table, by clicking on the table name wp_comments, then click on the SQL tab
  6. use an sql query to mass delete spam comments in WordPress by typing the following in the Run SQL Query box:

    DELETE FROM wp_comments WHERE comment_approved = 0

    Click Go, click OK.

  7. Comments deleted!

If you are using a spam catcher, like Akismet, the value for comment_approved may be set to “spam”, so you’ll need to alter the query as follows:

DELETE FROM wp_comments WHERE comment_approved = ‘spam’

Don’t forget to use the single quote marks to enclose the word spam.

Verify that the number of records in the comments table has been reduced to the number of approved comments. Hooray!

Optimize the WordPress database by going to the Structure tab, or clicking on the database name in the left column, and at the bottom of the table listing click on “Check tables having overhead”. Choose “optimize table” from the spin box on the right and all the extra space that those nasty spam comments took up will be released and the database optimized.

Go back to database view and verify that the overhead space has been removed. The size column now represents the space that is actually used by the database.

Refresh your WP blog and the spam comments will be gone. Isn’t is great to see ZERO spam comments?!

Alternatively, you can catch spam before it lands in your WP blog by modifying the function.php file in your theme using these excellent directions from Tejaswini.

Also, try Soumen Halder’s list of ways to reduce comment spam on WP blogs.

Reblog this post [with Zemanta]

Website Analytics Options Beyond Google

If you have any interest in knowing where your website traffic is coming from and what brought them to your site, you need to use some type of analytics software to learn these things.

As with any kind of software, there are free and open source alternatives to paid versions. The one pay-software for site stats worth mentioning here is called Mint and is found at haveamint.com. It’s a totally configurable way to look at your site stats. If you don’t have many web properties, the $30 per site license isn’t too bad.

Let’s take a look at the software that doesn’t cost anything but an investment of time….

Site statistics are included in CPanel which comes with most hosting packages. Once you sign in to CPanel, look under the Logs section for Awstats or Webalizer Stats. More people seem to talk about using Awstats, but if you go to Webalizer Stats and click on any month name under the summary you’ll get all the same data that is provided by Awstats. Pick one whose layout is easy to read and you’ll have your site statistics at your fingertips.

Google Analytics (GA) is geared towards marketers and can easily be integrated with an Adwords or Adsense account, both from Google. If you want to formulate a plan for meeting sales goals or increasing conversions, the big G can help you when you link your existing accounts. Some folks have written that they don’t trust Google and don’t want Big Brother knowing their every move online, so they shy away from using a GA account.

Instead, you could rely on a free alternative called statcounter. Visit statcounter.com and click on the features page. You’ll see many of the same items listed that occur in your CPanel stats options. The downside to using statcounter or GA is that you’ll have to dig into the page code and insert a few lines of code. It’s not that hard, but it does take a little time to set up. You only have to set it up once, though.

If you’re running a WordPress blog, try the stats plugin found at http://wordpress.org/extend/plugins/stats/ for a pretty look at your site stats.

Reblog this post [with Zemanta]