Listen sharp time to run a command inside a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Listen sharp time to run a command inside a script
# 8  
Old 08-10-2017
Code:
#!/bin/bash  cd /home/database
  command 1
if [ today is monday ]
then
    nohup monday &
fi
repeat for other days of the week.
...... 
 exit 0

Code:
#monday
current_time=hour * 3600 +min *60 +sec
runtime=19*3600
if current_time less than runtime
 sleep (runtime - current_time)
  do stuff
else
echo too late for today
fi

---------- Post updated at 10:35 PM ---------- Previous update was at 10:16 PM ----------
This User Gave Thanks to jgt For This Post:
# 9  
Old 08-14-2017
Hello,
I am sorry for my delayed return
I will test it tomorrow and keep you posted about the result


Thanks
Boris
# 10  
Old 08-15-2017
Not sure if you are still after this or in the meantime something else. (It might be beneficial to describe in plain text what exactly you want to do and maybe we find a better solution with a completely different way of attacking this.)

Quote:
Originally Posted by baris35
Code:
command 1
if time is 19:00, day is Monday then run command2
if time is 20:00, day is Tuesday, then run command3
if time is 22:00, day is Friday, then run command4
if time is 00:00, day is Thursday, then run command5

This can easily be done with several cron jobs and you don't need a script for it. Put the following in crontab:

Code:
0 19 * * 1 command1 >/dev/null 2>&1 ; command2 >/dev/null 2>&1
0 20 * * 2 command1 >/dev/null 2>&1 ; command3 >/dev/null 2>&1
0 22 * * 5 command1 >/dev/null 2>&1 ; command4 >/dev/null 2>&1
0 0 * * 4 command1 >/dev/null 2>&1 ; command5 >/dev/null 2>&1

"0 19 * * 1" i.e. means: at 19:00 every Monday, "0 0 * * 4" means at 00:00 every Thursday, and so on. See man crontab or man cron for details.

I hope this helps.

bakunin
# 11  
Old 08-15-2017
Hello Bakunin,
Thanks for the info you shared. I am a bit familiar with crontab. I am not sure that I can do what I am trying to do exactly. Let me go in deeper to make it more clear:


my script
Code:
cd folderA
For i in *.mp4
do
ffmpeg -i $i -c copy -f mpegts pipe:1
done

if time is 19:00, go to folder B
ffmpeg -i 1.mp4 -c copy -f mpegts pipe:1
mv 1.mp4 /played_video/1.mp4
when 1.mp4 ends, 
ffmpeg -i 2.mp4 -c copy -f mpegts pipe:1
mv 2.mp4 /played_video/2.mp4

if time is 21:30 go to folder A
for i in *.mp4
do
ffmpeg -i *.mp4 -c copy -f mpegts pipe:1
done

Here is the explanation of my aim in text plain.
I need to make the script running in FolderA and play all video files, one by one, without interruption. When time is 19:00, it should suddenly stop playing the mp4 files in FolderA and should go to FolderB. Then stream 1.mp4 and pipe it. when 1.mp4 finishes, move it to the folder played_video, then stream 2.mp4 with ffmpeg in pipe mode. When stream process of 2.mp4 is finished, move it to played_video folder etc..
Then go back to folderA and keep streaming all files.
As I am piping in folder B, for some reason, I am also unable to move processed file at the end of each process.

Kind regards
Boris

Last edited by baris35; 08-15-2017 at 04:30 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Run awk command inside ssh

I am trying to run an awk command inside of ssh and it is not working. These are AIX servers. for i in `cat servers`; do ssh $i "/bin/hostname; df -g | awk '/dev/ && $4+0 > 70'"; done server1 server2 server3 server4 I also tried these two methods and they did not work. It just seemed... (5 Replies)
Discussion started by: cokedude
5 Replies

2. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

3. Shell Programming and Scripting

Run bash command inside zsh script

Hi, I would like to run following code in bash inside a zsh script. (In this case is output unfortunately very different if you run it in zsh). I tried to put "bash" in front of the code but I obtained following error message "bash: do: No such file or directory " eve though I merged the whole... (7 Replies)
Discussion started by: kamcamonty
7 Replies

4. Shell Programming and Scripting

Run .exe inside shell script

I have to run some shell scripts in Windows using Cygwin. I am able to achieve that using %BASH% --login -i "/cygdrive/d/script.sh" , where %BASH% is an environment variable in Windows set to C:\cygwin\bin\bash.exe. I have a created a Cygwin environment variable $EXE_PATH =... (3 Replies)
Discussion started by: HemanthJayasimh
3 Replies

5. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

6. Shell Programming and Scripting

Bash- Command run from script does not pass full parameters with spaces inside

There's a JavaScript file that I call from command line (there's a framework) like so: ./RunDiag.js param1:'string one here' param2:'string two here' I have a shell script where I invoke the above command. I can run it in a script as simple as this #!/bin/bash stuff="./RunDiag.js... (4 Replies)
Discussion started by: AcerAspirant
4 Replies

7. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

8. Shell Programming and Scripting

how to run shell script inside expect script?

I have the code like this : shell script continues ... .... expect -c" spawn telnet $ip expect "login:" send \"$usrname\r\" expect "Password:" send \"$passwd\r\" expect "*\>" send \"$cmdstr\r\" ... (1 Reply)
Discussion started by: robbiezr
1 Replies

9. Shell Programming and Scripting

Run the command inside perl script

I have a command which will run fine in a unix command prompt. Can you tell how to interprete this command inside perl script...... The command is : perl -pe 's/(\|333\}.*)\}$/$1|1.6}/' FIA.txt This will search for the number 333 and appends 1.6 at the end of that line....... (1 Reply)
Discussion started by: vinay123
1 Replies

10. Shell Programming and Scripting

How to run an SQL script inside a shell

How do I create a K Shell which would silently (without user input) logon to Oracle and run an SQL script? Any help will be greatly appreciated. Steve (1 Reply)
Discussion started by: stevefox
1 Replies
Login or Register to Ask a Question