I'm trying to run a shell script in (#!/bin/sh in HP-UX) on exact times(hh:mm:ss) hh:05:00 .. hh:10:00 .. hh:15:00 .. hh:20:00 .. hh:25:00 and so on. I understand this could be done using cron but I'm looking for another way to do this.  Adding: watch/repeat are not supported
92677
There's a built-in Unix command repeat whose first argument is the number of times to repeat a command, where the command (with any arguments) is specified by the remaining arguments to repeat.  For example,  % repeat 100 echo "I will not automate this punishment."   will echo the given string 100 times and then stop.  I'd like a similar command – let's call it forever – that works similarly except the first argument is the number of seconds to pause between repeats, and it repeats forever.  For example,  % forever 5 echo "This will get echoed every 5 seconds forever and ever."   I thought I'd ask if such a thing exists before I write it. I know it's like a 2-line Perl or Python script, but maybe there's a more standard way to do this. If not, feel free to post a solution in your favorite scripting language.  PS: Maybe a better way to do this would be to generalize repeat to take both the number of times to repeat (with -1 meaning infinity) and the number of seconds to sleep between repeats. The above examples would then become:  % repeat 100 0 echo "I will not automate this punishment." % repeat -1 5 echo "This will get echoed every 5 seconds forever."
55825
How to execute a script periodically like crontab does but without using crontab?  Please note this that the executed script should not fire with another script and schedule it with 'sleep' command, what I expect to have same functionality as crontab but it should not be present in crontab list and should not be stop when terminal or session ended,   crontab exactly but without croning it.
114750
I'm searching for the possibility to execute a shell script or command based on idle time in the bash shell.  As an example, if I'm in a SSH session to a server of mine and after X minutes of inactivity in the terminal, I want a command to start a desired program like cmatrix, and when I come back and press a key I will get back where I left.
1396
I want to write a crontab that opens Firefox every minute (just to test it, I know it doesn't make any sense). My problem is that even though crontab is active nothing happens. This is how my crontab looks like:  SHELL=/bin/bash PATH=~/bin:/usr/bin:bin * * * * * export DISPLAY=:0.0 xhost localuser /usr/bin/firefox   Any idea why it isn't working?
55862
I have a script that checks to see if port 4000 is open and listening, if it is return true, else start a service that also outputs a logfile. The script runs fine if I execute it as a user, but if I add it as a cron it doesn't run. I'm logged in as root, the script is owned by root, the script has executable permissions, and I am running crontab -e as root.   #!/bin/bash if lsof -Pi :4000 -sTCP:LISTEN -t &gt;/dev/null ; then     return 1 else     seoserver -p 4000 start &gt; /var/www/vhosts/domain.com/httpdocs/seoserver.log &amp; fi   And here is my cron  */5     *       *       *       *       /usr/bin/seoStart
96679
I'm running on a couple of different Linux distros (Fedora 11, CentOS 5 and SuSE 10.2) and  often run into a problem where a new script that I want to run as a cron job works fine when called direct from the command line, but fails when called from cron due to slight variations in the PATH or other required environment variables.  Is there a way I can test run an individual script as if it's being run from cron, without having to run the entire crontab or use run-parts to run the entire cron.daily/ .hourly etc. directory ?  I guess I could temporarily edit my crontab to run the script in the next couple of minutes, but I'd rather have a more standalone solution so that I don't risk messing up the crontab.
70961
I am looking for a method built-in to ubuntu that will allow me to run a script or program or whatever for a fixed period of time.  , but the package is unavailable for Ubuntu. In any case, I was hoping for something built-in.  The only thing i can think of is to get the current time and set a cron job 30 minutes from 'now' that will kill the program.  I was hoping there was a way to do this without setting up a script, but if I need to - it wont be the end of the world. After the 30 minute interval I would like to put my laptop in a sleep mode, but this can be separate from the timer thing.  Thanks in advance.
42192
I need a shell script which finds files which are created 1 hour before or 1 hour after a particular file (test.txt) was created.   If I go with find -newer, that means I'd have to create a temporary file, use touch to change the time on that 1 hour before the creation time of the test.txt file, and then use -newer tempFile to find the files which are newer than the tempFile, ultimately finding the files which are created 1 hour before the test.txt file. Then I have to go back through that process to find those an hour or more older than the file I'm interested in. That seems like a lot of extra work to go through to answer a simple question.  I also see find -mmin, but I worry that it's an extension to POSIX find.  Any other suggestions?
93360
I'm trying to run a command at 10 minutes after 2am every weekday only.  In my launchd .plist file, how can I specify this?    I don't want it to run every 2 hours and 10 minutes, just once every weekday at the specified time.
29790
Can some one tell me the logic or the entire script to create a shell script to send a mail to me once every 20 days
6379
I want to create a log file for a cron script that has the current hour in the log file name. This is the command I tried to use:  0 * * * * echo hello &gt;&gt; ~/cron-logs/hourly/test`date "+%d"`.log   Unfortunately I get this message when that runs:  /bin/sh: -c: line 0: unexpected EOF while looking for matching ``' /bin/sh: -c: line 1: syntax error: unexpected end of file   I have tried escaping the date part in various ways, but without much luck. Is it possible to make this happen in-line in a crontab file or do I need to create a shell script to do this?
79666
Question  I'd like to be able to run a UNIX command precisely every second over a long time period.  I need a solution, which does not lag behind after a certain time, because of the time the command itself needs for execution. sleep, watch, and a certain python script all failed me in this regard.  On the microcontroller's such as the  I'd do that through hardware clock interrupts. I'd like to know whether there is a similar time-precise shell script solution. All the solutions which I found within StackExchange.com, resulted in a noticeable time lag, if run over hours. See details below.  Practical purpose / application  I want to test whether my network connection is continuously up by sending timestamps via nc (netcat) every 1 second.  Sender:  precise-timestamp-generator | tee netcat-sender.txt | nc $receiver $port   Receiver:  nc -l -p $port &gt; netcat-receiver.txt   After completion, compare the two logs:  diff netcat-sender.txt netcat-receiver.txt   The diffs would be the untransmitted timestamps. From this I would know at what time my LAN / WAN / ISP makes troubles.     Solution SLEEP  while [ true ]; do date "+%Y-%m-%d %H:%M:%S" ; sleep 1; done | tee timelog-sleep.txt   Gets a certain offset over time, as the command within the loop also takes a little time.  Precision  cat timelog-sleep.txt  2012-07-16 00:45:16 [...] 2012-07-16 10:20:36   Seconds elapsed: 34520  wc -l timelog-sleep.txt   Lines in file: 34243  Precision summarized:   34520-34243 = 277 timing problems 34520/34243 = 1.008 = 0.8 % off   Solution REPEAT PYTHON  Found at:   repeat.py 1 "date '+%Y-%m-%d %H:%M:%S'" &gt;&gt; timelog-repeat-py.txt   Supposed to avoid the time offset, but fails to do so.  Precision  wc -l timelog-repeat-py.txt  2012-07-16 13:42:44 [...] 2012-07-16 16:45:24   Seconds elapsed: 10960  wc -l timelog-repeat-py.txt   Lines in file: 10859  Precision summarized:   10960-10859 = 101 timing problems 10960/10859 = 1.009 = 0.9 % off   Solution WATCH  watch -n 1 "date '+%Y-%m-%d %H:%M:%S' &gt;&gt; ~/Desktop/timelog-watch.txt"   Precision  wc -l timelog-watch.txt 2012-07-16 11:04:08 [...] 2012-07-16 13:25:47   Seconds elapsed: 8499  wc -l timelog-watch.txt   Lines in file: 8366  Precision summarized:   8499-8366 = 133 timing problems. 8499/8366 = 1.016 = 1.6 % off.
10868
If script.sh is just something typical like  #!/bin/bash echo "Hello World!"   Is there a preferred way to run the script? I think you first have to chmod it so it becomes executable?
21713
I have Anacron set up to run a backup daily, weekly and monthly. The monthly seems okay, but the daily and the weekly are running roughly every half hour every day! Here is my /etc/anacrontab # /etc/anacrontab: configuration file for anacron                                                                                                                                                                            # See anacron(8) and anacrontab(5) for details.                                                                                                                                                                              SHELL=/bin/sh                                                                                                  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin                                              HOME=/root                                                                                                     LOGNAME=root                                                                                                                                                                                                             # These replace cron's entries                                                                                 1       5       cron.daily      run-parts --report /etc/cron.daily                                             7       10      cron.weekly     run-parts --report /etc/cron.weekly                                            @monthly        15      cron.monthly    run-parts --report /etc/cron.monthly                                                                                                                                           # PERIOD        DELAY   IDENTIFIER      COMMAND                                                                @daily  3       Rsnapshot_daily /root/scripts/rsnapshot_launcher.sh daily                                      @weekly 15      Rsnapshot_weekly        /root/scripts/rsnapshot_launcher.sh weekly                             @monthly        30      Rsnapshot_monthly       /root/scripts/rsnapshot_launcher.sh monthly  I've checked /var/spool/anacron/Rsnapshot_daily and it has todays date in it and was last updated less than 30 minutes ago. It's now 6pm and the daily Rsnapshot task has been run 11 times today and the weekly 10 times so far. What could be going on here? Thanks. (this is on Kubuntu 20.04 LTS)
61729
How can I write this with an AIX script correctly?  My requirement is to write this command in test.txt:  clock=$(prtconf -s | awk '{print $4,$5}')   I tried this command:  print 'clock=$(prtconf -s | awk '{print $4,$5}')' &gt; test.txt   Output written in test.txt gives me:  clock=$(prtconf -s | awk {print ,})   If I use " " quotes:  print "clock=$(prtconf -s | awk '{print $4,$5}')"   It gives me directly to:  clock=3612 MHz   How can I solve this?
51391
Is there a way to add lines to a user's cron via script?  I usually do it using crontab -e, but I would like to automate this task with a shell script.
68053
I created 3 daily cron jobs to run.  Below are the three that are placed in etc/cron.daily  rkhunter.sh  #!/bin/sh ( rkhunter --versioncheck rkhunter --update rkhunter --cronjob --report-warnings-only ) | mail -s 'rkhunter Daily Run (my server)' me@email.com   chkrootkit.sh  #!/bin/bash chkrootkit | mail -s "chkrootkit Daily Run (my server)" me@email.com   logwatch.sh  #!/bin/sh ( logwatch ) | mail -s 'logwatch Daily Log (my server)' me@email.com   I replaced me@email.com ofcourse with my email.  If I run this cronjob manually it works fine ./nameoffile.sh  But it doesn't run daily, what can be the cause or how can I check into this?