Best way to schedule a task that is be excuted years later


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Best way to schedule a task that is be excuted years later
# 1  
Old 01-20-2010
Best way to schedule a task that is be excuted years later

What is the best way to schedule a task that is be executed years later? Like execute a script after 4 years.

Is cron the best method for that?

Any other option other than cron/at ? Smilie
# 2  
Old 01-20-2010
Code:
$ date -d "+4 years " +%s
1390194960
$ date +%s
1263964545

So add one if-then command in your script, such as: (not tested)

Code:
if [ `date +%s` > 1390194960 ]; then 
#  Your script here
fi

You can run the script every day by cronjob.
# 3  
Old 01-20-2010
You can use at, with either of these syntaxes:
Code:
at 201401201200
at +4 years

Note that the first one uses a 24 hour format.
# 4  
Old 01-20-2010
Yes, cron / at is a best option.

But it depends, You have to be sure that, nobody will edit your cron entry ( say, two or three admins then somebody may ? ).

But in case of at, you have to remove it by finding the at job id. So you might find that better suited for you, where as in cron all the CRON jobs will be given for edit with 'crontab -e'.
# 5  
Old 01-20-2010
To remove all the 'at' jobs :
Code:
atrm $(atq|cut -f1)

# 6  
Old 01-20-2010
Will the task set using at get reset on reboot ?
# 7  
Old 01-20-2010
YES ! Smilie
Another advantage is that if the computer is down at the specified time, at will run the job at bootub.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Schedule task on some date and time.

Hi ! all I am interested to know how to schedule some task, say delete some directory which needs root privileges, please someone suggest me other than crontab Here is a scenario schedule date is 25-09-2013 time 10:00 AM to 11:00 AM delete directory log in following path ... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies

2. Shell Programming and Scripting

How to do one line bash schedule task?

This seems to work: https://www.unix.com/shell-programming-scripting/179705-how-run-cygwin-bash-windows-scheduled-task.html However, I was hoping to avoid writing a 2 line bat files to invoke my cygwin scripts as a scheduled task (since I'm making lots scheduled tasks). I was hoping this would... (1 Reply)
Discussion started by: siegfried
1 Replies

3. What is on Your Mind?

40 years of chips

I've been thinking about modern CPUs. Apart from x86 and SPARC, is there any other 'kind' of CPU used today in computers (not in playstation3, phones and similar) (6 Replies)
Discussion started by: orange47
6 Replies

4. Shell Programming and Scripting

Need to stop script for until present command excuted

Hi, Basically I am running a script in another script. #!/bin/sh DIRECTORY="/export/home/scripts" CURDATIME=`date '+%m%d%y_%H%M%S'` LOG_FILE="${DIRECTORY}/${CURDATIME}_abc.out" echo "ABC Delta Script started at `${CURDATIME}`" > $LOG_FILE cd ${DIRECTORY} sh ./abcDeltaRun.sh >>... (1 Reply)
Discussion started by: tnrchinna
1 Replies

5. UNIX for Dummies Questions & Answers

Unix Command to separate this years files and last years?

Hello - I have a folder that contains files from 2003 till 2010. I am trying to figure out a command that would seperate each years file and show me a count? Even if i can find a command that would give me year by year count, thats good enough too. Thanks (8 Replies)
Discussion started by: DallasT
8 Replies

6. Shell Programming and Scripting

Parse an XML task list to create each task.xml file

I have an task definition listing xml file that contains a list of tasks such as <TASKLIST <TASK definition="Completion date" id="Taskname1" Some other <CODE name="Code12" <Parameter pname="Dog" input="5.6" units="feet" etc /Parameter> <Parameter... (3 Replies)
Discussion started by: MissI
3 Replies

7. Shell Programming and Scripting

Retrive the value returned by a command excuted in a remote server using ssh

Hello Everybody, I'm facing a weird problem with the awk command. I try to retrieve in a variable the value returned by a simple ls command. ls /export/home/tmp |tail -1 return a good value (the name of the . But When I try to execute the same command in a remote server using ssh as... (2 Replies)
Discussion started by: Jabarod
2 Replies

8. Shell Programming and Scripting

comment and Uncomment single task out of multiple task

I have a file contains TASK gsnmpproxy { CommandLine = $SMCHOME/bin/gsnmpProxy.exe } TASK gsnmpdbgui { CommandLine = $SMCHOME/bin/gsnmpdbgui.exe I would like to comment and than uncomment specific task eg TASK gsnmpproxy Pls suggest how to do in shell script (9 Replies)
Discussion started by: madhusmita
9 Replies
Login or Register to Ask a Question