Archive

Posts Tagged ‘cron’

Ubunut Scheduled System Shutdown with Notification

Step1: Install ‘gnome-schedule’ which is a graphical user interface to manage your crontab file
cmd: apt-get install gnome-schedule

Step2: Install ‘libnotify-bin’ which sends desktop notifications to a notification daemon.
cmd: apt-get install libnotify-bin

Step3: Configure notification in user account.
*Login into the user account in which the notification to be enabled.
*Navigate to Application->System Tools->Schedules tasks to open ‘scheduled tasks’.
*Click ‘Add new task’ to add new entry in cronjob.
*Select the type as ‘A task that launches recurrently’.
*In Description, enter the title of the job.
*In Command, Copy and paste the following script.
/usr/bin/notify-send -t 15000 ‘system will automatically shutdown in 15 min,so properly close everthing before system shutdown!!!’
* Select ‘X Application’ from the below drop down.
*Set the time to run this job before 15 mins of system shutdown job(next we will configure).

1

Step4: Configure shutdown command in root account.
*Navigate to Application->Accessories->Terminal to open Terminal.
*Login into root account by using ‘su root’ command.
*Enter the password of root.
*Enter the following command to edit crontab file(open with nano editor).
cmd: crontab -e

2

*Set the crontab entry as follows.
00 21 * * * /sbin/shutdown -h now

3*Save and exit.
Note: ‘ctl+o’ to save, then press ‘ENTER’ to conform the file, then ‘ctl+x’ to exit.

4

Go home without tension……

Mysql backup script with date & time stamp

June 25, 2013 Leave a comment

Mysql Script:

#!/bin/bash
mysqldump -u root -p(yourpasswd) –routines –databases databasename > destination/folderpath/in which dump file to be stored/name.sql
thetime=`date +%Y-%m-%d–%H:%M:%S`
mv /dump file location/bugs.sql /destination of dump file with date and time stamp/name-$thetime.sql

Sample Script:

#!/bin/bash
mysqldump -u root -proot –routines –databases bugs > /home/jug/Desktop/mysql/bugs.sql
thetime=`date +%Y-%m-%d–%H:%M:%S`
mv /home/jug/Desktop/mysql/bugs.sql /home/jug/Desktop/mysql/bugs-$thetime.sql

Thats it..

Categories: Linux Tags: , , , , ,