LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-05-2013, 05:33 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,133

Rep: Reputation: 45
From command line to a crontab script


Dear all,
I have been using the following command

rsync -rav -e ssh /home/user/Documents/Documents-Sensitive/ user@server:/home/user/Documents/

to do backups, in the terms of having a duplicate of the files somewhere else (server).

I would like now to turn this
1.into a script and
2. make it running every two days at 3:00 at night.
3. with low process and io priority (I think there is nice for processes and nice for io access)

Is that possible in Linux and how?
Could you please help me start filling in the missing parts of the puzzle?

Regards
Alex
 
Old 02-05-2013, 08:04 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,564
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
Quote:
Originally Posted by alaios View Post
Could you please help me start filling in the missing parts of the puzzle?
You recently asked about rsync and scripts, so instead of asking:
Quote:
Originally Posted by alaios View Post
I would like now to turn this into a script and
may we expect you at least show use a rudimentary script with the actual commands you have used?
That would show what you understood of those threads and besides it's easier to correct.


Quote:
Originally Posted by alaios View Post
make it running every two days at 3:00 at night.
See 'man 5 crontab' examples and post your proposed crontab line instead.


Quote:
Originally Posted by alaios View Post
with low process and io priority (I think there is nice for processes and nice for io access)
Yes, there's 'nice' and 'renice' (as in 'renice +20 -p $$' ;-p). For I/O see 'man ionice'.
Do post the commands as you think you'll use it. (Also these days there's also cgroups but let's not get into that.)
 
Old 02-05-2013, 10:24 AM   #3
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,133

Original Poster
Rep: Reputation: 45
Thanks I gave the script that I am using

rsync -rav -e ssh /home/user/Documents/Documents-Sensitive/ user@server:/home/user/Documents/

for all the rest some help is needed. I do not want ready made solutions but mostly where to look and then someone to validate if I did it correct

Alex
 
Old 02-05-2013, 10:29 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,564
Blog Entries: 54

Rep: Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927Reputation: 2927
See 'man 5 crontab' examples and post your proposed crontab line instead.
There's 'nice' and 'renice' (as in 'renice +20 -p $$' ;-p). For I/O see 'man ionice'.
Do post the commands as you think you'll use it.
 
Old 02-06-2013, 01:19 AM   #5
mlbx
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Rep: Reputation: Disabled
You can get help with the part of the puzzle about crontab timing values at www.CronBuddy.com
 
Old 03-28-2013, 06:33 AM   #6
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,133

Original Poster
Rep: Reputation: 45
Hi all,
would it be able to have cron to do something like that:

- Run the script two times a month (example, every second Saturday)
- Two specific dates of the months like the 10th and the 20th.

Regards
Alex
 
Old 03-28-2013, 07:02 AM   #7
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,031

Rep: Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335
can you read the man page? just look for the string "every second Saturday"
 
Old 03-28-2013, 09:41 AM   #8
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,133

Original Poster
Rep: Reputation: 45
nothing came
 
Old 03-28-2013, 11:45 AM   #9
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,031

Rep: Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335Reputation: 1335
http://www.unix.com/man-page/Linux/5/crontab/
 
Old 03-28-2013, 02:57 PM   #10
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,577
Blog Entries: 1

Rep: Reputation: Disabled
Code:
#!/bin/bash
rsync -rav -e ssh /home/user/Documents/Documents-Sensitive/ user@server:/home/user/Documents/
save it, chmod 700 the script.
Your 3am cron will use it, so remember it's name and location.
 
Old 03-29-2013, 02:47 AM   #11
mlbx
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Rep: Reputation: Disabled
This cron simulator is now at http://www.dataphyx.com
 
Old 04-02-2013, 07:05 AM   #12
mlbx
LQ Newbie
 
Registered: Jan 2013
Posts: 7

Rep: Reputation: Disabled
Quote:
Originally Posted by mlbx View Post
You can get help with the part of the puzzle about crontab timing values at www.CronBuddy.com
This interactive cron sandbox is now at http://www.dataphyx.com
 
Old 04-20-2013, 05:02 AM   #13
fredak
Member
 
Registered: Apr 2013
Location: Montgeron near Paris
Distribution: Slackware
Posts: 32

Rep: Reputation: Disabled
Quote:
Originally Posted by alaios View Post
Hi all,
would it be able to have cron to do something like that:

- Run the script two times a month (example, every second Saturday)
- Two specific dates of the months like the 10th and the 20th.

Regards
Alex
Hi Alex

minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)

if you put
50 13 8-14 * 6 your_task

it doesn't mean between the 8th and the 4th IF it is saturday (which is 6)
It will do : each day between the 8th and the 4th AND ALSO on every saturday

so what you will have to do is test the date
50 13 8-14 * * if [ `date +%u` = 6 ];then your_task;fi

in this case, your_task will be launched on the 2nd saturday or the month

put another line for the fourth saturday :
50 13 16-22 * * if [ `date +%u` = 6 ];then my_task;fi

Fredak
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash functioning with command line or crontab GianniC Linux - Software 5 01-14-2013 06:14 AM
my database export shell script run from command line but not form crontab saifee Linux - General 11 01-29-2012 10:24 AM
crontab fails but command line works - sir-lancealot Linux - Server 3 02-19-2011 05:43 PM
C++ prorgam runs OK from command line, but failed from crontab vgolden Linux - Software 2 01-21-2005 12:00 PM
shell script works form command line but not form crontab saifee General 1 10-14-2004 11:27 AM


All times are GMT -5. The time now is 02:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration