What's new

Cron timer to run .sh

glyn1978

Newbie
Can anyone help me out? im trying to set my h2s to run a .sh command i have that i use to create a bouquet of my iptv channels. The script works fine when i manually ssh it. However i was thinking of making a crontimer to run this script automatically so it auto updates my iptv bouquet if new channels have been added. But i cant get it to work.

So far
I have added #!/bin/bash to the start of the command i normally manually run (I was advised this was needed to make it a script rather than a command).
I saved as a .sh file. I put it in the same folder as the .sh scripts already used by the image (/usr/scripts)
i used contab -e in putty to create and edit a crontimer. but it doesnt seem to run correctly. im presuming theres something wrong with the .sh file im trying to run

Thanks in advance.
 
HI there,

im just wondering if you ever found a solution to this? I have also tried as you have done above aswell as the usual linux methods and adding the command to rcS file in init.d,
Crontab just doesn't seem to execute my script regardless of how i keep formatting it
No success for me yet though, interested to hear your experience.

Thanks.
 
This is what I used to create a cron timer to run the script. Ignore the script generator section, that was just for my provider. Replace xxxxxx.sh with your script name.......hopefully what I have detailed below will help, it definitely worked for me.



1. Open putty and login as root
2. Go to the script generator, log in with your credentials and copy the script (same script that you run initially to set up the bouquets)
3. Create a script called xxxxxx.sh :
a) At the command prompt type vi xxxxxx.sh
b) Press <esc> then i to put you into insert mode in vi
c) Press right mouse button to paste your clipboard content into the script you are creating.
d) Then press ZZ to save the file and exit
4. Hopefully now you should have a script called xxxxxx.sh in /home/root directory.
5. You can verify this by typing at the command prompt ls –l
6. You can verify the content of the file by typing more xxxxxx.sh
7. Next you need to make the script executable. Do this by typing chmod u+x xxxxxx.sh
8. You can verify the script works by manually running it with ./xxxxxx.sh (this will import your bouquets/content again and reboot the box)
9. Once you have verified the script works, you can schedule it by adding it to the cron. To do this type crontab –e
10. Now you need to use vi commands again. First down arrow to the last line and then append a new line at the end type <esc> then a for append then press return.
11. The cursor should be on the start of a new line
12. Next type the following, this will schedule the script to run at 6am daily (but you can change to your liking):
00 06 * * * /home/root/xxxxxxx.sh > /home/root/logs/sleek.log 2>&1
13. Then type ZZ to save and exit
14. You can verify the contents of the crontab by typing crontab –l
You don’t necessarily need this part ‘> /home/root/logs/sleek.log 2>&1’ so you can leave this bit out but it just saves the content of script run in case something didn’t work and you needed to check what it did.
 
Back
Top