Kamis, 11 Juli 2013

Run crontab Every 10 Minutes

Q. How do I run a cron job or a shell script every 10 minutes using Linux / UNIX cron service?

A. cron is a time-based scheduling service in Linux / Unix-like computer operating systems.
Login to UNIX system
Type the following command to enter cronjob:
$ crontab -e
Each cronjob has following syntax:
# +---------------- minute (0 - 59)
# |  +------------- hour (0 - 23)
# |  |  +---------- day of month (1 - 31)
# |  |  |  +------- month (1 - 12)
# |  |  |  |  +---- day of week (0 - 6) (Sunday=0 or 7)
# |  |  |  |  |
  *  *  *  *  *  command to be executed
To get crontab to run a task every 10 minutes you could type as follow
*/10 * * * * /path/to/command
Save and close the file.

Solaris Flash Archives

Flash images or flar image is very useful in situations where you need cloning/imaging or crashed server recovery. The flarcreate command creates a flash archive. A flash archive can be created on a system that is running a UFS root file system or a ZFS root file system. A flash archive of a ZFS root pool contains the entire pool hierarchy except for the swap and dump volumes and any excluded datasets. The swap and dump volumes are created when the flash archive is installed.


NOTE: By default, the flarcreate command ignores items that are located in "swap" partitions.

Let's see how we can work with flar image creation.

Create the archive:


For UFS:

# flarcreate -n "Solaris 10 10/09 build" -S -c -x /var/tmp/ /var/tmp/S10-1009.ufs.archive.sun4u-`date +'%Y%m%d%H%M'`

For ZFS:

# flarcreate -n "Solaris 10 10/09 build" -S -c /var/tmp/S10-1009.zfs.archive.sun4u-`date +'%Y%m%d%H%M'`


Where -


The "-n Solaris 10 10/09 build" implants a name into the FLAR image. The name should be something unique and meaningful to better identify it as the FLAR image for the system.

The "-x /var/tmp/" option causes the /var/tmp/ directory and its contents to be excluded from the FLAR image since it will not be needed in the FLAR image.

-S option causes to skip the disk space check and do not write archive size data to the archive. Without -S, flarcreate builds a compressed archive in memory before writing the archive to disk, to determine the size of the archive. The result of the use of -S is a significant decrease in the time it takes to create an archive.

-c Tells flar to compress the archive as it's writing it.


E.g. -


# time flarcreate -n "Solaris 10 10/09 build" -S -c /var/tmp/S10-1009.zfs.archive.sun4u-`date '+%m-%d-%y'`


Full Flash
Checking integrity...
Integrity OK.
Running precreation scripts...
Precreation scripts done.
Creating the archive...
Archive creation complete.
Running postcreation scripts...
Postcreation scripts done.


Running pre-exit scripts...
Pre-exit scripts done.


real 19m58.57s
user 13m42.99s
sys 1m55.48s



# ls -l /var/tmp/S10-1009.zfs.archive.sun4u*
-rw-r--r-- 1 root root 5339709933 Oct 14 04:54 /var/tmp/S10-1009.zfs.archive.sun4u-10-14-10


# flar info /var/tmp/S10-1009.zfs.archive.sun4u-10-14-10
archive_id=2f27a01690ce4fcaf398e638fcdcb66e
files_archived_method=cpio
creation_date=20101014093417
creation_master=XXXXXX
content_name=Solaris 10 10/09 build
creation_node=XXXXXXXX
creation_hardware_class=sun4u
creation_platform=SUNW,Sun-Fire-V240
creation_processor=sparc
creation_release=5.10
creation_os_name=SunOS
creation_os_version=Generic_142900-09
rootpool=rpool
bootfs=rpool/ROOT/s10s_u8wos_08a_Pre-patch
snapname=zflash.101014.04.10
files_compressed_method=compress
content_architectures=sun4c,sun4d,sun4m,sun4u,sun4s,sun4us
type=FULL


Also we can have a small shell script to create flar image -


#!/bin/sh
echo
echo Enter image name, i.e. Solaris build e.g. S10-1009.ufs.archive.sun4v
read ANS
echo "Image Name: ${ANS}" > /etc/image_catalog
echo "Image Created on: `date`" >> /etc/image_catalog
echo "Image Created by: `/usr/ucb/whoami` on `hostname`" >> /etc/image_catalog

#
# Clean up wtmpx so that new machine won't have last logins
#
cat /dev/null > /var/adm/wtmpx
#
# Now create flar, excluding -x /var/tmp/
#
flarcreate -n ${ANS} -c -a `/usr/ucb/whoami` -x /var/tmp/ /var/tmp/${ANS}_`date +'%Y%m%d%H%M'`

Senin, 08 Juli 2013

HDG Guide – Storage Spaces and Pools in Windows 8

Windows 8 offers a new feature called Storage Spaces that gives you more drive setup options than before. If you utilize external drives, multiple internal drives or even network storage, you can use the Storage Spaces feature to not only manage the drives, but also customize the setup of the drives.
Storage Spaces
Here are a few additional details regarding storage spaces, from Microsoft.com.
To get started with Storage Spaces in Windows 8, first launch the Control Panel using the path Charms > Settings > Control Panel. Once at the Control Panel, scroll down the page to find the Storage Spaces listing. Click Storage Spaces to launch the Storage Spaces utility.
Storage Spaces Window
If you’ve not used the Storage Spaces option before, you will be presented with the option Create a new pool and storage space. Select it to navigate to the Create a storage pool screen.
The Create a storage pool screen lists all of the available drives that are eligible to be used as storage space. It also prompts to let you know that anything on the drives will be deleted during configuration.
Create a Storage Pool
Proceed to click (check) any drives that you would like to utilize in the storage pool and click the Create pool button to proceed with adding a Storage Space.
Create Pool External Hard Drive
The next screen is the configuration page, which allows you to define which type of storage space to setup. The selectable options will vary, depending on how many extra drives you are using. Lets run through the options quickly.
Create a storage space
Name and drive letter
Name: – Enter a name for the drive. For example: External hard drive 1, External Hard Drive 2, or Storage Drive, etc…
Drive letter: Choose a drive letter/identifier for the particular drive so that Windows can assign it.
Resiliency
Simple (no resiliency) – A simple storage space writes one copy of your data to the drive, and doesn’t protect you from drive failures. A simple storage space requires at least one drive. – Basically, the drive is used for an extra storage volume.
Two-way mirror – A two-way mirror storage space writes two copies of your data, helping to protect you from a single drive failure. A two-way mirror storage space requires at least two drives. – A mirrored solution that utilizes one drive and then mirrors the data to another drive, protecting your from data loss should one of the drives fail.
Three-way mirror – A three-way mirror storage space writes three copies of your data, helping to protect your from two simultaneous drive failures. A three-way storage space requires at least five drives.
Parity – A parity storage space writes your data with parity information, helping to protect you from a single drive failure. A parity storage space requires at least three drives.
RAID and protected backup has never been simpler. Depending on how many external hard drives you have connected to the PC, you can choose one of the resiliency options based on your needs.
Once you’ve configured the options for the Storage Space, click the Create storage space button.
Create Storage Space
From here, Windows will configure and format the storage space.
Formatting Storage Space
Once that has completed, the Storage Pool will be active in the main window.
Storage pool
Now, you can simply navigate to the Computer pane and the freshly added Storage Space should be active and ready to use.
Storage Space complete
That’s basically all there is to it for using the Storage Spaces feature. In this tutorial, we used one external hard drive and set it up as a Storage Space. Thus, the drive is simply being used as an external storage solution, or extra volume. However, if you utilize multiple drives, you will be able to configure the drives using more options and structures. Enjoy!

Can’t Change Date and Time in Windows 7

I recently ran into a problem on one of my Windows 7 machines where I could not change the date and time. Every time I clicked on the Change Date and Time dialog box shown below, I kept getting an error message.
change date and time The message that kept popping up was:
Unable to continue. You do not have permission to perform this task.
I had previously had some problems with this machine and thought it might be related. In the end, I had to try a couple of different solutions before I stopped getting the error message about not having permission. Hopefully, one of the solutions will work for you.

Method 1 – Safe Mode

One thing you can try is to change the date and time in Safe Mode. If you are able to change it here, you then know it’s a problem with either a startup item or a Windows service. You can then perform a clean boot of Windows 7 to narrow down the issue.
You can check out this article from Microsoft that details how to perform a clean boot in Windows 7:
http://support.microsoft.com/kb/929135
clean boot

Method 2 – System File Checker

The next thing you can try is to run the system file checker. If you’re having strange permission issues in Windows, it’s probably some type of corruption of system files and settings. You can run SFC by opening a command prompt and typing in the following command:
sfc /scannow
sfc scannow System file checker will verify all system files and will replace any file that is corrupt, modified or damaged.

Method 3 – Command Line

You can also change the date and time in Windows using the command line. Open a command prompt and type in the word date and press enter. You’ll be prompted to enter a new date.
new date What about the time? Pretty easy too. Just type in the word time and you can change the time too:
change time Note that the time is in 24-hour format and you can specify it down all the way to milliseconds. You should be able to change the time without having to open an elevated command prompt. If you get an error, however, then try running the command prompt as Administrator.

Method 4 – Local Security Policy

If you get an error message like “A required privilege is not held by the client” when trying to use the command prompt, go to Control Panel, Administrative Tools, Local Security Policy and then navigate to Local Policy\User Rights Assignment and ensure that Change the system time and Change the time zone privileges are given to Administrators.
local security policy Note that if you are in a domain, you may simply be restricted by the group policy set by your company. If you’re not on a domain and Administrators don’t have the two privileges shown above, then adding the group to the security setting should fix the problem.

Method 5 – Windows Time Service

If you’re still having problems changing the date and time in Windows, go to Control Panel, Administrative Tools and click on Services. Scroll down to Windows Time and right-click and choose Properties. Click on the Log On tab and make sure it’s set to This account – Local Service.
windows time service The password fields should automatically be filled in, so there is no need to type in any passwords. Go head and restart the computer and see what happens.

Method 6 – Uninstall Third-Party Clock Applications

If you have any third-party clock manager or time programs, go ahead and uninstall them and see if that resolves your issue with changing the Windows date and time. Sometimes a conflict can occur and a third party program might prevent you changing the time.
Hopefully one of the solutions above fixes your issue. If not, post a comment here and I’ll try to help. Enjoy!

Troubleshoot a Failed Hard Drive

If you get a BSOD or other random error with the Windows operating system, it is usually assumed to be because of a virus, malware or other software error. If you’ve gone through all of the proper troubleshooting steps regarding PC viruses and other Windows software, but still are getting an error with the operating system, it may be due to a failing or erroneous hard drive.
hard drive failure
If any PC part is to fail, or at least cause errors within the Windows OS, it’s most likely the hard drive. Sometimes, PC parts can fail without notice, leaving Windows in a non-functional state or with poor performance or random errors. In today’s article, we will review some ways that you can troubleshoot a basic hard drive.

Hard Drives

Hard drives are one of the most common computer parts that fail without notice. Additionally, hard drive errors can cause many types of Windows errors.
Checking a Hard Drive for Errors
If you can boot into Windows, you can use the built-in CHKDSK function to help troubleshoot a failing hard drive or hard drive with errors.
Begin by launching the Start Menu and selecting Computer. This will queue the Computer window, which lists all of the PC’s active drives.
Windows Computer Pane
In most cases, the internal and primary hard drive for a PC will be the Local Disk (C:) drive. However, it may be different depending on your PC’s drive setup. From the Computer pane, locate the PC’s hard drive and right-click it. From the context menu, select the option Properties.
This will launch the Properties dialog for the specific drive.
Local Disk Properties
Click the Tools tab and select the Check now option to check the hard drive for errors.
Windows Error Checking
Can’t Boot Into Windows
If you cannot boot into Windows, then you also have the option of running the CHKDSK function (mentioned above), from Windows Recovery Console. You will need a functional PC with Windows to create a System Repair Disc. As Microsoft notes, creating a System Repair Disc can be done using the following steps:
System Repair Disc
Upon booting from the system repair disc, you can run CHKDSK, but additionally, the disc has a few other utilities that can help repair and troubleshoot a Windows operating system that will not boot. Remember, for failed or erroneous hard drives, the objective is to be able to boot into Windows so that you can backup any important files or data from the drive.
Data Recovery
If none of the above options are suitable, then you can also attempt data recovery, if the hard drive has important files or data that you absolutely need. Data recovery is a bit more work, but it can be worth it in some situations.
Data recovery is complex, and can involve advanced drive troubleshooting using fdisk and commonly, specialty recovery software. If the hard drive has errors, is completely corrupt and won’t boot into Windows, you may be able to recover files simply by removing the drive from the PC and using a hard drive enclosure to connect the drive externally to an existing Windows PC. From there, you may be able to use specialty software to manually browse the Windows based disk using file structure, and manually move important files or data to another drive.
Additionally, to learn more about hard drives and complex data recovery options, you may want to check out PCStats Beginner’s Guide to Hard Drive Recovery.
Complete Reformat and Erase
In a scenario where Windows won’t boot and even the System Repair option fails to fix the hard drive, you should consider performing a complete reformat and erase, before considering the drive to be a vegetable and throwing it to the garbage. In some cases, such as a complex rootkit virus, Windows may have system level errors, in which a hard drive format is the best option.
To completely format and erase an internal PC hard drive, you can create a bootable formatting disc. For this, you may want to check out DBAN, or Darik’s Boot and Nuke. Upon booting from a DBAN disc, you can wipe the primary PC hard drive using some basic command line.
A failed Hard Drive
Worst case scenario is a completely failed hard drive that may have a failed spindle, arm or platter.
Hard Drive Components
In a case where the actuator/arm or other mechanical component has failed, you may want to consider the drive to be done with. However, if you have extremely important data on the drive, and the platters are still intact and undamaged, you may be able to swap the platters to an identical drive and repair the drive, which would ultimately give you the option to recover your PC data.
This requires an advanced technical understanding of hard drives, calibration and more. So, in most cases, it would be better to have a tech or data recovery specialist do this, rather than attempt it yourself.
Those are a few ways that you can troubleshoot, recover, diagnose and fix hard drive errors and failed hard drives. Thank you for stopping by the site for today’s post. Enjoy!

Refresh, Reinstall or Restore Windows 8

In Windows 8, you actually have three main options for recovering the operating system: refresh, reinstall and restore. While all of these options can be used to recover Windows, they all operate a bit differently.
windows_8_logo Each of the following Windows 8 recover methods performs a specific type of operating system reset:
  • Refresh
  • Reinstall
  • Restore
By choosing the according recover method for your particular scenario, you may be able to save yourself some time and also reinstall Windows properly. Here are some tips for using each of the main recover methods.

Refresh – You can refresh without losing your photos, music, videos and other personal files

The Windows 8 Refresh option allows you to refresh Windows while still keeping your personal files and data that you have saved on your PC. As described in Windows 8, here’s what will happen if you Refresh a PC:
Refresh your PC
  • Your files and personalization settings won’t change.
  • Your PC settings will be changed back to their defaults.
  • Apps from the Windows store will be kept.
  • Apps you installed from discs or websites will be removed.
  • A list of apps will be saved to your desktop.
To Refresh your PC in Windows 8, start by launching the Charms menu and clicking the Settings listing. Next, select the Change PC Settings option.
change_pc_settings Scroll down to the General listing and click the Get started button listed under Refresh your PC without affecting your files.
refresh your pc without affecting files You can also check out my previous post on creating your own Windows 8 backup image, which will allow you to install all of your apps and programs, create your image and then be able to restore to that image instead of losing all your programs.

Reinstall – Remove everything and reinstall Windows

The Windows 8 reinstall option allows you to completely reinstall the operating system without having to manually reformat the hard drive and install using a Windows 8 disc or USB drive. When you reinstall Windows 8 using the Reinstall option:
  • All of your files, data, apps, programs and Windows settings will be removed. Windows will completely reinstall itself and your PC will be completely revert to a fresh Windows 8 installation.
  • No prior PC data or saved data will be transferred to the fresh install.
To Reinstall Windows 8, start by launching the Charms menu and selecting the Settings listing. Select the Change PC settings option from the menu.
change_pc_settings Scroll down to the General listing and select it. From the right-side submenu, locate the Remove everything and reinstall Windows option and click the Get started button.
Remove everything and reinstall Windows

Restore – Restore Windows from an Earlier Time (System Restore Point)

The Windows 8 Restore option allows you to restore, or roll back Windows to an earlier time when a System Restore point was created. This option reverts Windows to the state of the System Restore point. Here are a few details of how the Restore option operates:
  • System restore does not affect any of your documents, pictures or other personal data.
  • Recently installed programs and drivers might be uninstalled.
To restore Windows 8, start by launching Control Panel. From the Control Panel, scroll down to the Recovery listing and click to select it.
Control Panel Recovery From the Recovery window, select the Open System Restore option.
Open System Restore This will launch the System Restore panel, where you can select a System Restore point to revert Windows to.
System Restore Those are the three main ways to recover the operating system in Windows 8. Thank you for stopping by the site for today’s post. Enjoy!

Troubleshoot Windows Explorer Has Stopped Working

There are some Windows errors that are masterpieces, meaning they have been around since the beginning of time and never fail to go away. One that pops into my mind is “Windows has recovered from a serious error”. If you search Google for that, you’ll find thousands of entries! Another one like that is “Windows Explorer has stopped working”.
explorer stopped working And sure enough, I got one of these error message on my Windows 7 PC last week. The problem with these errors and the reason why they are so popular is because they have all sort of causes. It’s not just one issue that causes the error, otherwise it would be easy to fix. In this article, I’ll try to go through all the different methods you can use to fix the error.

Method 1 – Perform a Clean Boot

The hunt it on! This problem is normally caused by something on your computer other than the OS. Windows itself rarely crashes on it’s own with this error. So the first thing to do is try and isolate what service, program or startup item is causing the issue, if it’s one of those.
You can do this by performing what is called a clean boot. It’s described here in detail on the Microsoft website:
http://support.microsoft.com//kb/929135
Basically, we use MSCONFIG to disable all third-party services and startup items and see if the problem goes away. If it does, then you know it’s one of those services or startup items and you have to start a cycle of enabling half the items, then rebooting, checking, etc. It’s a little time consuming, but worth it to have your computer running properly.
clean boot

Method 2 – Disable Shell Extensions

If you perform a clean boot and the issue is still occurring, then you can try to disable all non-Microsoft shell extensions. You can do this by downloading a free program from Nirsoft called ShellExView.
shellexview You want to run the program and then sort all the items by Manufacturer. Anything that is not from Microsoft should be disabled. Again, if the issue goes away, then you know it’s one of those shell extensions and you can enable them one by one. To disable, just select the item and then click on the red circle button.

Method 3 – Update Video Driver

Oddly enough, an old or corrupted video driver can cause this issue. Go to the manufacturer’s website and download the latest version for your version of Windows, making sure to get 32 or 64-bit depending on your system.

Method 4 – Always Show Icons

Another strange fix is to go to Explorer, Tools, Folder Options and then the View tab for Windows XP. For Windows Vista and 7, you want to click on the Organize button, then Folder and Search Options, then View tab.
tools folder options On the View tab, check the box that says Always show icons, never thumbnails.
always show icons What does this do? Well, basically instead of trying to show a small thumbnail preview of a picture or video, it will just show an icon. That may not be ideal, but if it gets rid of the problem of explorer not responding, then it might be worth it.

Method 5 – System Restore

If you installed something like an update or a new driver and now all of a sudden you are having the explorer problem, it might be a good idea to restore your computer to a previous state. You can use System Restore to go back to a time before the update or installation that you believe is causing the problem. Click Start and type System Restore.
system restore

Method 6 – Run System File Checker

If this problem happens to be caused by a corrupted file in Windows, which is pretty rare, you can fix it using a few different tools. The first one is running the system file checker command at the command prompt. You can do this by opening an elevated command prompt (Click Start, type command and then right-click and choose Run as Administrator).
run as admin At the command prompt, simply type in the following command:
sfc /scannow
sfc scannow This will check all system and protected files and replace them if any of them are found to be corrupted. If this does not work, you can try a repair install.

Method 7 – Repair Install Windows

startup repair You can get to startup repair from the System Recovery Options dialog shown above when the computer first loads. Basically, you need to press and hold F8 while your computer is booting. Then you’ll get the list of Advanced Boot Options, where you will choose Repair your computer.
repair your computer Click Startup Repair and let it do it’s thing. Also, while you are in the System Recovery Options, you’ll see an option for Command Prompt. From there, you can try running the following command:
chkdsk c: /r

Method 8 – Virus or Malware Removal

If absolutely nothing else is working for you, then you may be a victim of a virus or malware. If you think you may have a virus, you should try to install some anti-virus and anti-spyware software to see if you can find any problems. If you have a really bad virus infection or lots of malware, your only choice may be to do a fresh install of the OS.
If you’re still having this problem, post your specs here, anything you had done recently on your computer and we’ll try to help! Enjoy!