Due to your query I have installed cron at windows using CYGWIN_NT and started cron service.
1. Create a shell script file
Example:
Code:
$ cat /home/murugesandins/mycron.sh
#!/bin/bash
/usr/bin/date "+%a %d-%b-%Y %I:%M:%S %p %Z" >> /tmp/output.txt
$ chmod +x /home/murugesandins/mycron.sh
Create cron job
Add following lines:
Code:
#There is no option to mention seconds. Hence use sleep... to execute at related timings
#Minute Hour DayOfMonth MonthOfYear DayOfWeek Create six cron job to execute at each 10 seconds.
* * * * * ( /usr/bin/sleep 10;/home/murugesandins/mycron.sh )
* * * * * ( /usr/bin/sleep 20;/home/murugesandins/mycron.sh )
* * * * * ( /usr/bin/sleep 30;/home/murugesandins/mycron.sh )
* * * * * ( /usr/bin/sleep 40;/home/murugesandins/mycron.sh )
* * * * * ( /usr/bin/sleep 50;/home/murugesandins/mycron.sh )
* * * * * ( /usr/bin/sleep 60;/home/murugesandins/mycron.sh )
Save and quit
Each 10/20/30/40/50/60 seconds the output written at /tmp/output.txt
Example:
Code:
$ cat /tmp/output.txt
Wed 01-May-2024 08:38:11 PM IST
Wed 01-May-2024 08:38:21 PM IST
Wed 01-May-2024 08:38:31 PM IST
Wed 01-May-2024 08:38:41 PM IST
Wed 01-May-2024 08:38:51 PM IST
Wed 01-May-2024 08:39:01 PM IST
Wed 01-May-2024 08:39:11 PM IST
Wed 01-May-2024 08:39:21 PM IST
Wed 01-May-2024 08:39:31 PM IST
Wed 01-May-2024 08:39:41 PM IST
Wed 01-May-2024 08:39:51 PM IST
Wed 01-May-2024 08:40:01 PM IST
Wed 01-May-2024 08:40:12 PM IST
Wed 01-May-2024 08:40:22 PM IST
Wed 01-May-2024 08:40:32 PM IST
Wed 01-May-2024 08:40:42 PM IST
Wed 01-May-2024 08:40:52 PM IST
Wed 01-May-2024 08:41:02 PM IST
Wed 01-May-2024 08:41:11 PM IST
Wed 01-May-2024 08:41:21 PM IST
Wed 01-May-2024 08:41:31 PM IST
Code:
$ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.1ohnI6c1ek installed on Wed May 1 20:32:21 2024)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
#Minute Hour DayOfMonth MonthOfYear DayOfWeek Create six cron job to execute at each 10 seconds.
* * * * * ( /usr/bin/sleep 10;/home/murugesandins/mycron.sh )
* * * * * ( /usr/bin/sleep 20;/home/murugesandins/mycron.sh )
* * * * * ( /usr/bin/sleep 30;/home/murugesandins/mycron.sh )
* * * * * ( /usr/bin/sleep 40;/home/murugesandins/mycron.sh )
* * * * * ( /usr/bin/sleep 50;/home/murugesandins/mycron.sh )
* * * * * ( /usr/bin/sleep 60;/home/murugesandins/mycron.sh )
$ crontab -r
$ crontab -l
no crontab for murugesandins