Run Tasks/Jobs in the Background while closing the SSH Session

We usually run imports and exports for our email marketing software using PHP-CLI (Command-line Interface). The problem comes when we want to work on something else. Instead of opening multiple terminal sessions, we use this little application called Screen. This little application is quite handy when it comes to keeping those sessions alive by running tasks/jobs in the background. Screen is a console application that allows you to have multiple terminal sessions within a single window.

If you don’t have it installed, you can install it by using the following command:

sudo apt-get update
sudo apt-get install screen

To use:

screen -dmSL [session name] [commands]

d – starts a session and immediately detaches from it
m – forces the creation of a new session
S – lets you give the session a friendly name
L – turns on logging to ~/screenlog.0

To detach and keep the processes running:

Ctrl + A + D

To resume the session:

Screen -x "session-name"

Easy Way to Keep Your Ubuntu/Debian Instances Updated

While updating our proxy servers, I had to create a new Ubuntu instance for testing. I also realized most of our instances were outdated. Having an outdated instance poses a security risk. New updates generally patch up any vulnerabilities discovered and new features are added to your instance which may prove beneficial.

I’ve always found it a hassle to update instances and automating the update isn’t necessarily good as sometimes it requires a manual restart. Most people update by using sudo apt-get update && sudo apt-get upgrade command to catch anything available for their system. These two commands may not actually catch everything or may leave behind outdated files that could lead to problems down the road. Ofcourse, you can always use apt-get autoremove and apt-get clean but what if I told you there is a single command that could do all this.

Say Hi to uCareSystem. With a single command, it does the following…

  • Update all available packages
  • Update your Ubuntu system
  • Download and install updates
  • Check for the list of old Linux Kernels and uninstall them
  • Clear the apt cache folder
  • Uninstall packages that are obsolete and no longer needed
  • Uninstall orphaned packages
  • Delete package settings (from software you have previously uninstalled)


1) Login to your server
2) Add the necessary repository

sudo add-apt-repository ppa:utappia/stable

3) Update apt

sudo apt-get update

4) Install the software

sudo apt-get install ucaresystem-core

Once complete, you are good to go!


Type in the following…

sudo ucaresystem-core

You will see something like this when its all done.

Hope this will help in keep your instances updated. Good luck!


Simple way to check if CRON is working!

Recently, we moved from hosting our app on Amazon EC2 instances to Elastic Beanstalk Service. For those who had a go at hosting their apps on Elastic Beanstalk, you would know the struggles with .ebextensions. There are far more documentation and examples available now than when it was first released into the market. One of the most challenging things to do in Beanstalk is running Cron. The recommended way of doing it is via the creation of worker environment that processes long-running workloads on demand or performs tasks on a schedule. It makes use of other Amazon services like SQS queuing.

This is okay for some people who have genuinely long-running processes but our PHP application was pretty straightforward. Most of the CRON jobs would be completed in seconds. For us, running a separate worker instance with all its resources was pointless and a waste of resources. So we need to come up with another way. The other way of running CRON is using something called “leader_only” declarations in the .ebextension file. By using that, you are asking Beanstalk to run the CRON Jobs only on the first instance. This avoids multiple instances running the same CRON jobs because that would really screw things up.

Anyway, we need to get the YAML right and there is a neat little utility online that lets you validate your files. It’s called Check it out. To see if your CRON is running as it should, here is a neat little way to test it. Obviously, the whole point of using Beanstalk is to avoid having to manually edit code on single instance so it takes away the need to setup FTP or sFTP. I suggest you do set it up for your first instance so you can check if the CRON is running and if everything is deploying as it should. There is no harm done in double checking right 😉

1. Edit your CRONTAB or in Beanstalk’s case, add it to the .ebextension folder.

$ crontab -e

2. Add the following line inside your CRON which basically will append the current date to a log file every minute. The 6 fields of the crontab file are minute, hour, the day of the month, month, the day of the week, and the actual command.

* * * * * /bin/date >> /tmp/cron_output

3. Exit the editor and you should see an output something similar to this.

crontab: installing new crontab

4. Check if the CRON is running every minute as it should through running this command which grabs the output of the file being stored in /tmp directory.

tail -f /tmp/cron_output

You should see something similar to this as the output.

Mon Apr 23 00:01:01 PDT 2018
Mon Apr 23 00:02:01 PDT 2018
Mon Apr 23 00:03:01 PDT 2018
Mon Apr 23 00:04:01 PDT 2018

If you don’t see it regularly running every minute, then you know something is not right with the CRON service. If you don’t see the file at all, then you know the CRON is not running. This narrows down things down to what is working and what isn’t. Saves you some hours on figuring out whether its Elastic Beanstalk file playing around or your actual CRON commands or something else. Hope this helps 🙂

I will be writing the way we setup CRON in the future blog post. Watch the space!


Deleting Magento Customer Address Programmatically

When upgrading Magento for one of our customers, we’ve realized somehow all the shipping information were half complete. It either had a region filled out without address or zip code. When you enter that customer’s profile and try to save it, it wouldn’t save because these are required fields. This was causing these old customers to purchase stuff from the store because they assumed their address was saved.

The best thing to do when you encounter such an issue with Magento is to clear saved addresses altogether. Our team has written a neat little script that would delete all the saved addresses given that you know their email addresses. This is easy to find out if you were to just export all customer profiles through Magento panel. Some might argue that you can do this Data Profiles Import/Export function. Unfortunately, Magento has a function to replace only if the value contains something. If you leave it blank, it wouldn’t touch that field. So you would still have the customers whose addresses are half filled with missing information.

I hope this helps someone in need 🙂

  $customer_emails = array(
    "[email protected]",
    "[email protected]"
  foreach($customer_emails as $customer_email){
    echo $customer_email . "</br>";
    $customer = Mage::getModel("customer/customer");
    $customer->loadByEmail($customer_email); //load customer by email id
    $customer_id = $customer->getId();
      echo $customer_id. "</br>";
      foreach ($customer->getAddresses() as $address)
         $customerAddress[] = $address->toArray();
    echo '<pre/>';print_r($customerAddress );


#DEV Software

Lessons Learnt from Heavy Loss Due to Fraudulent Transactions

We have lost $1,000s from Credit Card Disputes arising from fraudulent transactions within a year of trading from just one of our software products. Crazy, right? We thought so too. So here’s what we’ve learned from this experience on protecting our businesses from fraudulent transactions. For business owners, seeing disputes come through could be probably the worst nightmare. As online service providers, we experience this more than offline retailers. In the simplest of terms, I think, it all comes down to having adequate proof in delivering your service and the lack of credit card being present when the funds are deducted.

Our credit card payment processor Stripe is a game changer in this industry. They process billions of dollars worth of transactions in any given time frame. Before them, I think, companies have relied heavily on PayPal to transact from their potential customers. PayPal had a competitive advantage because most of the transactions required users to have a PayPal account before he/she could purchase anything online. Over time, as with any business, without continuous innovation, newer products are highly likely to take your place in the industry. I think this is what happened with PayPal and Stripe. Stripe came along pleasing the right crowd (developers) to get on board with them. They made it extremely simple for developers to implement payment solutions within their code.

They won us over. We started with them a couple of years ago. They treated us well but their customer service sucks. They don’t have phone support and you are better off solving your code-related issues than emailing them for help. It is really that bad. With that said, they do make an effort in preventing issues from occurring in the first place – Thanks to their detailed documentation. I love companies that follow the quote – prevention is better than cure. Try to address business issues before they become one. We’ve found people making these transactions seem to target services that they could benefit from instantly – like our email verification service. Since our entire system is automated, once they make use of our service, there is no way we can stop them from getting what they “supposedly” paid for. With that said, here is a list of things that we found useful in reducing our rate of fraudulent transactions.

Be upfront with your customers – I think honesty is the best policy. Tell them exactly what they are going to be charged and when they will be charged again. I’ve seen a lot of businesses trying to sneakily charge their customers with hidden charges or ongoing subscriptions. This gets them by surprise and chances are very high for them to launch a fraudulent dispute against you although they were the very ones who’ve used their credit card for making that purchase. As a seller, you have no way of proving to the banks (mostly because they don’t care about what you have to say) that the transaction was a valid one. We used to send a single email receipt from our system for successful payments. Now all of our customers receive two emails – one from our credit card processor (Stripe) and the second one from our system telling them exactly what they have been charged and who they can contact regarding these charges if something doesn’t look right.

Make sure what you are offering is valuable to your customers – This again comes back to point one where customers will launch a dispute if they don’t find value in what they just bought. I am guilty of the times when I launched a dispute due to this reason. It was when a business talked about these great product features but when I went ahead with the purchase, I realised it was nothing like what they said it would be like. So, offer a service or product that you know is honestly priced and deliver what you have promised. If it didn’t add value, the best thing to do is to give out refunds. Remember that saying, the customer is always right? It’s true. You rather not have a customer who is disappointed in what you offered – trust me, they can do real bad things to your business. A good example is bad reviews. You can serve 1000 customers who are all happy but get 1 customer who is not happy, they will search the internet for all the review sites that they could write about the bad experience they had dealing with your company. One dissatisfied customer is enough to threaten your hard earned reputation over the years.

Communication is crucial – Think of it like real life relationships. The reason two people won’t get along is because of communication issues. They both aren’t in the same place together – one is thinking something completely different to what the other has on their mind. Add actions into the mix and you end up having people form opinions as to what’s happening. The same analogy applies to your business and customers. You have to sort it out before it becomes an issue. Keep things simple – communicate and sort things out with your customers. Be there for them when they need you – live chat, phone, and email support are just some of the way you can do this. In our early days of launching our product, our team was so focused on making our software better than we neglected our customers. We have learnt the hard way and we probably could have prevented a lot of miscommunication and lost customers. Be honest with your customers – I have seen so many companies hide and deny any bugs that have caused disruptions. This is what annoys a lot of customers. If you are wrong, admit it! I have apologised to many customers in the past for bugs that we had in our system. In fact, I credited their account for pointing it out although we knew it was there already. Take care of them as they are the ones who are going to help you grow as a business. Think of them as your pillar of strength.

Just emailing doesn’t cut it. This goes back to point #3. You cannot rely just on emailing your customers. Being in the email industry for 5 years, we understand a bit about the complex infrastructure that is needed to get your email deliverability up. Spam filters, blacklists, whitelists, suppressed emails, soft bounces – these are just some of the things that could affect your email deliverability. This is why we moved into multi-channel communication. The aim is to reach your customer and address his/her needs before they reach you. Some of the best companies in the world succeed on a grand scale because they communicate with their customers through multiple channels. From our experience, in-app notification works amazingly well. There is something about “Seen” status in Viber that gets me going. I am so happy each time I see that word “Seen”. These days I seem to see that a lot more than getting a reply back but this is what you need for your business. You want to know if the customer has seen your message and that he/she understands what’s going on. They love being informed so make sure you reach them in any way you can to avoid miscommunication and frustration from their end.

Get as much detail about your customer as possible. These days nearly all SaaS apps are racing towards making sign ups as seamless as possible. While this is great for your customers, it is not good for your payment providers or for checking fraudulent activity. Till recently, we have asked only the most basic information from our customers – their email address and their credit card details. We thought if we made this billing process as simple as possible, we would have fewer headaches to deal with. It worked out quite the opposite for us. We had a lot more headaches because we knew so little about our customers. Less information collection is great during the initial sign up stage but when it comes to billing, you need to know more details. We realised that although Stripe doesn’t make it mandatory anymore to collect shipping/billing addresses, it can take in this information variables and pass it to the issuing bank. Using their new service to prevent fraudulent transactions – “Radar“, we can now decline charges that fail address verification. An email is automatically sent to the customer asking them to use the same address that they have with their credit card provider. This has cut down our fraudulent transaction rate significantly.

Hopefully, this information would come useful to those starting off their SaaS business. All the very best!