Need help in scripting
Hi All,
Situation Like this. iam runnning one script for every hour for sometask iam doing it through date variable so like this.. if time=12:00 |some task >infile if time=1:00 |some task >infile if time=2:00 |some task >infile so here i want to change time variable automatic for every after an hour and result should append. now iam running script for every hour manually.. i want to make it auto |
Quote:
eg. #!/bin/bash # This generates a file every 5 minutes while true; do touch pic-`date +%s`.jpg sleep 300 done for ref. http://tldp.org/LDP/Bash-Beginners-G...ect_09_02.html |
You should use cron, read the manpage for crond. With cron you can make a job done every hour.
As for the time variable, if you want to set a variable to the time you could use for example Code:
time=$(date +%F_%H) Code:
markus@samsung:~$ time=$(date +%F_%H) |
Cron ?
|
If your purpose is only to run your script per hour, then you can add it to crontab as:
Code:
0 */1 * * * /path/to/script |
cron is a program (one of several, but the most commonly-used because it's available on almost all systems) that schedules the running of other programs.
Instead of trying to handle the timing inside your script, so that it would have to be always running, make the script do the job only once, but set cron to run it when you need it to. Here are a couple of useful-looking links I just grabbed off the web: http://www.cyberciti.biz/faq/how-do-...-or-unix-oses/ http://kvz.io/blog/2007/07/29/schedu...using-crontab/ |
All times are GMT -5. The time now is 05:15 PM. |