Categories
#DEV

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)

Installation

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!

Usage

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!

Categories
Blog

That Beautiful Day…

#3Years

Categories
Uncategorized

Top 50 Restaurants

Categories
#DEV

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 YAMLlint.com. 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!

Categories
Blog

Restoring Google Authenticator 2-Factor Authentication Codes after iPhone Reset

Google Authenticator Iphone Restore

Recently Apple admitted to purposefully reducing the speed of an iPhone to conserve it’s battery life. In other words, they want people with older iPhones to go for a new one because the old ones seem slow and sluggish. As you would imagine, people didn’t take this in very well. There were tons of supporting and opposing articles around Apple’s decision to do this. Anyway, I have an older iPhone 6 Plus model and didn’t feel the need to upgrade (as of yet). And yes, it was slow and sluggish, so I decided to get my battery replaced hoping it would fix the problem. To my surprise, the wait time for a battery replacement of iPhone 6 Plus model was surprisingly long – close to 3 WHOLE months.

I couldn’t wait that long so I called up Apple and the nice guy on the phone ended up replacing my iPhone with a brand new one. He did charge me an out-of-warranty replacement fee but I was okay with that. The recommended procedure for moving your old phone’s data to the new phone is to use the iTunes back up and restore feature. I followed that and all the apps seem to be functioning the way they did.

If you have a lot of apps like I do, it does take quite a bit of time. You have to tap on each app for it to load as they get stuck sometimes. After the restore, it wasn’t amazingly fast but good enough to run the show. The only app that didn’t restore as it should be was the Google Authenticator app which is used for two-factor authentication. So heads up to all the developers out there moving their data to newer phones, Google Authenticator two-factor authentication codes would not be restored.

So you got two options…

  1. Log in to each of the sites you use 2FA on and switch off the 2FA
  2. If you have backup codes, you can reinstall Google 2FA and subsequent codes for each of the sites

Ps. To all the peeps wanting to get an iPhone 10/x, there are rumors that Apple would be releasing a plus version next year. I might or might not be waiting for that 😉