Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

What should I do to run a script on specific time without cron?

General Tech Bugs & Fixes
Max. 2000 characters
Replies

usr_profile.png
Rukhsar Fatima

User

( 7 months ago )

I want to run a script without using cron at specific time. But it is not working.

#!/bin/sh

DATE=`date | cut -d' ' -f4`

#Date is getting printed, if I run it manually, without any error. But file is not created at scheduled time.

echo $DATE

if [[ $DATE == "07:06:55" ]]
then
echo "this is a test program" >> xyz.log

fi

usr_profile.png
Jai Khanna

User

( 7 months ago )

 

If you want to run it only once, you can use the at command : https://en.wikipedia.org/wiki/At_(command)

Example :

echo "echo \"this is a test program\" >> /tmp/xyz.log" | at 1127 apr 11

If you want to run it every day, you might need to use a loop :

#!/bin/bash

while true;
do
    DATE=`date | cut -d' ' -f4`
    echo $DATE
    if [[ $DATE == "11:33:00" ]]
    then
            echo "this is a test program" >> xyz.log
            sleep 1s
    fi
done
 

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif