Is possible execute schedule task on Linux, for this we use the command cron or at. This post I will show how task schedule in your Linux.
Working the Cron
No doub the cron is very utilized for Linux administrator. Your interface is very simples, we will look your functions! Just open the terminal and type command:
crontab -e
Sometimes the terminal will ask to use a text editor, select your favorite editor.
See contrab configuration:
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
Look the last lines having: m h dom mon dow comand
Means
m------------------> Minutes 00 59
h ------------------> Hours 00 23
dom--------------> Month day 1 31
mon -------------> Month 1 12
dow-------------->Week day 0 7
command ----> Command to execute task
Use * to specify every minutes, days, month and etc.
Examples, we go configure task the a script for incremental backup every day at 9PM.
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
00 21 * * * /home/youruser/incremental\ backup.sh
Now every day at 9PM the cron run the script incremental backup.
Working the At
The command at is usefull to perform a task only once, example shutdown your computer.
The command At.
at HH:mm MM/DD/YYYY
Example on terminal
use@yourpc:$ at 20:00
at> shutdown -r now
press ctrl+d for save the task
For look the task scheduled type:
atq
For remove the task scheduled type:
atrm
quinta-feira, 28 de abril de 2016
segunda-feira, 25 de abril de 2016
Checking your file system with fsck
In some case, the file system may experience problems, we can fix with the fsck.
Make backup the files on partition with problem, you can create a image the disk our copy the files for other media.
This example we go utilize the partition /dev/sda5, now we go umount the partition with command umount.
sudo umount /dev/sda5
now type the command:
sudo fsck /dev/sda5
wait the fsck terminate the task.
Do not utilize the command for Windows file system, for this utilize the own Windows.
Never run the command with partition mounting, can corrupt the files.
This example we go utilize the partition /dev/sda5, now we go umount the partition with command umount.
sudo umount /dev/sda5
now type the command:
sudo fsck /dev/sda5
wait the fsck terminate the task.
Do not utilize the command for Windows file system, for this utilize the own Windows.
Never run the command with partition mounting, can corrupt the files.
terça-feira, 19 de abril de 2016
How install nvidia drivers on Ubuntu
This post i will show install Nvidia native drivers.
first click on dash or use Windows key on keyboard, type "Software & Updates", click in additional Drivers, wait the system search drivers. Select driver for your card video. Always prefer binary drivers propreitary and tested
segunda-feira, 18 de abril de 2016
How to rescue the grub boot load
Sometimes when we have two operational system on hard drive, example Ubuntu and Windows, can errors occur in the boot.
Possible causes.
The correction is simple, requires the Linux installation media installed.
Now you insert the media into the computer you need to fix the boot.
First open the terminal and run command with root.
#fdisk -l
See the partitions on the disk settings:
Disk /dev/sdb: 1000.2 GB, 1000200658432 bytes
255 heads, 63 sectors/track, 121600 cylinders, total 1953516911 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00087501
Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 976895 487424 83 Linux
/dev/sdb2 976896 196288511 97655808 83 Linux
/dev/sdb3 196290558 1953515519 878612481 5 Extended
/dev/sdb5 196290560 212289535 7999488 82 Linux swap / Solaris
/dev/sdb6 212291584 1953515519 870611968 83 Linux
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc92bea40
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1953516911 976757432 7 HPFS/NTFS/exFAT
This example show that partition /dev/sdb1 and /dev/sda1 are partition bootable. See that the partition /dev/sdb1 is my partition the boot on Linux and /dev/sda1 is partition the boot on Windows. Sure how the partition /dev/sda1 is partition primary, we will go record the bootloader the zero track HD. Use this command
#grub-install /dev/sda
Remember that Grub should be installed on the HD track zero, as I installed Windows first, the zero track is Windows partition.
Be careful not to confuse the live partition on the HD partition, Grub should be applied to HD partition.
An easy way to remember and which the system was first installed in HD, the first partition is where the zero track.
Possible causes.
- Update on Windows.
- Upgrade Windows on other version for Windows 10.
- Configuration boot loader on Windows.
- Lost boot loader on hard drive
The correction is simple, requires the Linux installation media installed.
Now you insert the media into the computer you need to fix the boot.
First open the terminal and run command with root.
#fdisk -l
See the partitions on the disk settings:
Disk /dev/sdb: 1000.2 GB, 1000200658432 bytes
255 heads, 63 sectors/track, 121600 cylinders, total 1953516911 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00087501
Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 976895 487424 83 Linux
/dev/sdb2 976896 196288511 97655808 83 Linux
/dev/sdb3 196290558 1953515519 878612481 5 Extended
/dev/sdb5 196290560 212289535 7999488 82 Linux swap / Solaris
/dev/sdb6 212291584 1953515519 870611968 83 Linux
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc92bea40
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1953516911 976757432 7 HPFS/NTFS/exFAT
This example show that partition /dev/sdb1 and /dev/sda1 are partition bootable. See that the partition /dev/sdb1 is my partition the boot on Linux and /dev/sda1 is partition the boot on Windows. Sure how the partition /dev/sda1 is partition primary, we will go record the bootloader the zero track HD. Use this command
#grub-install /dev/sda
Remember that Grub should be installed on the HD track zero, as I installed Windows first, the zero track is Windows partition.
Be careful not to confuse the live partition on the HD partition, Grub should be applied to HD partition.
An easy way to remember and which the system was first installed in HD, the first partition is where the zero track.
domingo, 17 de abril de 2016
How to access the file server from Windows to Linux
For this, we must know the IP our hostname the Windows File Server, and run the command:
#mount -t cifs -o username=username for access the file server, password= password for access your account on file server //IP our hostname the Windows/share folder /mnt
Now you will go for directory /mnt there is where the access point to the file server.
If you need to access more than one share, just create folders in the /mnt and point the share folder on mount command.
Example:
Assuming that the Windows server has folders: Company data and Human Resources.
Create directory on /mnt
#mkdir /mnt/company\ data
#mkdir /mnt/Human\ Resources
Now will go access Company data, okay?
#mount -t cifs -o username=username for access the file server, password= password for access your account on file server //IP our hostname the Windows/Company\ data /mnt/Company\ data
Now will go access Human Resources, we will repeat the above command replacing the folder
#mount -t cifs -o username=username for access the file server, password= password for access your account on file server //IP our hostname the Windows/Human\ Resources /mnt/Human\ Resources
This command works on all distributions.
#mount -t cifs -o username=username for access the file server, password= password for access your account on file server //IP our hostname the Windows/share folder /mnt
Now you will go for directory /mnt there is where the access point to the file server.
If you need to access more than one share, just create folders in the /mnt and point the share folder on mount command.
Example:
Assuming that the Windows server has folders: Company data and Human Resources.
Create directory on /mnt
#mkdir /mnt/company\ data
#mkdir /mnt/Human\ Resources
Now will go access Company data, okay?
#mount -t cifs -o username=username for access the file server, password= password for access your account on file server //IP our hostname the Windows/Company\ data /mnt/Company\ data
Now will go access Human Resources, we will repeat the above command replacing the folder
#mount -t cifs -o username=username for access the file server, password= password for access your account on file server //IP our hostname the Windows/Human\ Resources /mnt/Human\ Resources
This command works on all distributions.
sábado, 16 de abril de 2016
How to start application after user login
This configuration can be applied to all Linux distributions, for this we must edit .profile file that is in the user's home.
Before make the backup the file .profile, we do not want accident, ok!
cp ~/.profile .profile.bkp
Case need to restore.
cp ~/.profile.bkp .profile
Open and edit the file .profile on home directory the user.
I will use vi for this example, ok?
Example:
user@mypc:~$ vi .profile
well, now insert the name for application, for example Thunderbird the email client native for ubuntu and other distribuition.
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
thunderbid & #here is aplication for startup
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Now save the file.
Okay, now when the user logs into the system, the thunderbird will start.
Setting fixed IP on Linux Ubuntu and Debian
Sometimes we have to configure IP fixed in server and even on workstations.
In this article I will show to configure the IP on Debian and Ubuntu distributions.
Is good idea make backup this configuration before modify.
Use this command
#cp /etc/network/interface /etc/network/interface.bkp
If you want to restore settings
#cp /etc/network/interface.bkp /etc/network/interface
Now you have interface backup.
First check which interface is connected to your network
#ifconfig
eth0 Link encap:Ethernet HWaddr 94:de:80:f3:ca:94
inet addr:192.168.200.2 Bcast:192.168.200.255 Mask:255.255.255.0
inet6 addr: fe80::96de:80ff:fef3:ca94/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:71628 errors:0 dropped:0 overruns:0 frame:0
TX packets:55307 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:47699321 (47.6 MB) TX bytes:7476368 (7.4 MB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10114 errors:0 dropped:0 overruns:0 frame:0
TX packets:10114 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:826870 (826.8 KB) TX bytes:826870 (826.8 KB)
As in the example eth0 interface is connected with the IP 192.168.200.2
We most configure this archive /etc/network/interface
Use your favorite text editor, i like to use vi.
#vi /etc/network/interface
now let's edit the last line
auto eth0
iface eth0 inet static
address 192.168.200.100
netmask 255.255.255.0
gateway 192.168.200.1
Save configuration and after run the command
#/etc/init.d/networking restart
Another way to configure the IP is used ifconfig command , but every time the system is booted, IP configuration will not be saved.
#ifconfig eth0 192.168.200.100 netmask 255.255.255.0
After configure your gateway which command:
#route add default gw 192.168.200.1 eth0
In this article I will show to configure the IP on Debian and Ubuntu distributions.
Is good idea make backup this configuration before modify.
Use this command
#cp /etc/network/interface /etc/network/interface.bkp
If you want to restore settings
#cp /etc/network/interface.bkp /etc/network/interface
Now you have interface backup.
First check which interface is connected to your network
#ifconfig
eth0 Link encap:Ethernet HWaddr 94:de:80:f3:ca:94
inet addr:192.168.200.2 Bcast:192.168.200.255 Mask:255.255.255.0
inet6 addr: fe80::96de:80ff:fef3:ca94/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:71628 errors:0 dropped:0 overruns:0 frame:0
TX packets:55307 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:47699321 (47.6 MB) TX bytes:7476368 (7.4 MB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10114 errors:0 dropped:0 overruns:0 frame:0
TX packets:10114 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:826870 (826.8 KB) TX bytes:826870 (826.8 KB)
As in the example eth0 interface is connected with the IP 192.168.200.2
We most configure this archive /etc/network/interface
Use your favorite text editor, i like to use vi.
#vi /etc/network/interface
now let's edit the last line
auto eth0
iface eth0 inet static
address 192.168.200.100
netmask 255.255.255.0
gateway 192.168.200.1
Save configuration and after run the command
#/etc/init.d/networking restart
Another way to configure the IP is used ifconfig command , but every time the system is booted, IP configuration will not be saved.
#ifconfig eth0 192.168.200.100 netmask 255.255.255.0
After configure your gateway which command:
#route add default gw 192.168.200.1 eth0
Initialize script on startup the system
This article will show you how to start at system startup scripts in Ubuntu and Debian.
First we must create the script in /etc/init.d.
#vi /etc/init.d/myscript.sh
#!/bin/bash
sleep 10 &&
conky &
exit
After creating the script in the /etc/init.d we should give execute permission with the chmod command.
#chmod +x myscript.sh
Now we go using command:
update-rc.d /etc/init.d/myscritp.sh defaults
This exemple will go initialize the conky a software the hardware monitoring. When the system up, the script will initialize with the operational system.
If you want to remove the script from system startup:
First we must create the script in /etc/init.d.
#vi /etc/init.d/myscript.sh
#!/bin/bash
sleep 10 &&
conky &
exit
After creating the script in the /etc/init.d we should give execute permission with the chmod command.
#chmod +x myscript.sh
Now we go using command:
update-rc.d /etc/init.d/myscritp.sh defaults
This exemple will go initialize the conky a software the hardware monitoring. When the system up, the script will initialize with the operational system.
If you want to remove the script from system startup:
- You can delete the script
- Remove permission with the command
- Or remove the boot witch own update-rc.d
Assinar:
Postagens (Atom)