3

I am writing a bash (.sh) script for cygwin. I want to run a certain command at specific time.

I tried the following:

echo "test" | at 19:00

but I get the following error:

The AT command has been deprecated. Please use schtasks.exe instead.

So can I only use Scheduled Task in Windows for this?

2 Answers 2

4

The at command from Unix is not available on Cygwin. Cygwin has traditionally used the at command from windows, but this has been deprecated in favour of schtasks.exe.

So the answer to your question is yes: you can only use Scheduled Task in Windows for running a task once.

(You can use cron and set it on a specific date at a specific time... but it will repeat every year unless you remove the task from the crontab.) ;-)

1
  • All of my efforts to "run a command with arguments once at a specified time" have failed. schtasks.exe is NOT a suitable replacement for the unix at command. The later is actually usable. Jan 24, 2017 at 17:54
1

You can instead add a cron job.

Login from the user from which you want to execute the bash script.

Execute crontab -e command.

Now suppose if you want to run the bash script exactly on 19:00 on daily basis, then you need to add a line like this:

00 19 * * * /path/to/bash/script

Note: That script must have executable bit set for that user.

3
  • hmm... it does recognize crontab -e command. I looked it up online, it is my understanding that I need a cygrunsrv package for this
    – l3win
    Apr 12, 2013 at 15:55
  • Cron is for periodic jobs. This question is about a once-off. Apr 12, 2013 at 21:55
  • The answer is ok but you have to install the cron package first (using setup.exe of cygwin) .
    – DavAlPi
    May 24, 2013 at 14:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .