What's new

Scripts not running for cron - SOLVED

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Indyman

Occasional Visitor
Hi Everyone,
I'm trying to create a crontab in XVortex-Merlin (380.67) to wake up a server at a certain time. I have a script in /jffs/scripts called services-start to call the WOL file wol_nas.sh:
#!/bin/sh

#crontab for sending WOL packet to DADS_NAS at 10:55 pm every Sunday and 7:55pm
cru a Sunday_NAS_on "55 22 * * 0 /jffs/scripts/wol_nas.sh"
cru a Mon_NAS_on "55 19 1-7 * 1 /jffs/scripts/wol_nas.sh"
logger DADS_NAS is awake

The wol packet script wol_nas.sh is:
#!/bin/sh

sh /usr/sbin/ether-wake -b 192.168.1.255 00:19:d1:25:d3

Problem is when I run the wol_nas.sh script I get the error /usr/sbin/ether-wake: line 1: syntax error: unexpected word (expecting ")"). I also dont see the cron jobs (cru l). I have jffs scripts enabled in firmware and both scripts have been made executable. The syntax of the ether-wake statement appears correct to me (apparently it is not) and the broadcast and MAC addresses are correct. What am I doing wrong?
 
Looks like you created the files using a Windows editor.

dos2unix /jffs/scripts/services-start
dos2unix /jffs/scripts/wol_nas.sh
 
ColinTaylor
Thanks - I thought I had done that as I used Notepad ++ but apparently I didn't set the preferences correctly. I recreated both files
in Notepad++ with UTF-8 encoding, saved as Unix files (changed extension from .bash to .sh) and uploaded to jffs/scripts with WinSCP and then via PuTTY made both executable. The crontab was accepted after I ran the script manually (shows up with cru l). However when I try to run the wol_nas.sh script:
sh /usr/sbin/ether-wake -b 192.168.1.255 00:19:d1:25:d3
I get the same error message as before:
/usr/sbin/ether-wake: line 1: syntax error: unexpected word (expecting ")")
- where is the syntax error in line 1?
 
Last edited:
Remove the "sh " to get rid of that message.

But the parameters of the ether-wake command are wrong.

Code:
# ether-wake
BusyBox v1.25.1 (2017-07-20 06:47:38 MST) multi-call binary.

Usage: ether-wake [-b] [-i IFACE] [-p aa:bb:cc:dd[:ee:ff]/a.b.c.d] MAC

Send a magic packet to wake up sleeping machines.
MAC must be a station address (00:11:22:33:44:55) or
a hostname with a known 'ethers' entry.

        -b              Broadcast the packet
        -i IFACE        Interface to use (default eth0)
        -p PASSWORD     Append four or six byte PASSWORD to the packet

# /usr/sbin/ether-wake -b 94:de:80:c5:79:52
 
ColinTaylor,
Ah ok. I removed the "sh" and the broadcast IP - and it worked when run manually! Thank you! Unfortunately now it appears my services-start.sh doesn't run at boot time - only when I manually execute it. What should the file type be for the services-start file? I saved it as a Unix file (.sh) but I notice there is never a file extension when people list it when discussing. When you create the file and save it, what do you save it as? Could that be the problem?
 
ColinTaylor,
Ah ok. I removed the "sh" and the broadcast IP - and it worked when run manually! Thank you! Unfortunately now it appears my services-start.sh doesn't run at boot time - only when I manually execute it. What should the file type be for the services-start file? I saved it as a Unix file (.sh) but I notice there is never a file extension when people list it when discussing. When you create the file and save it, what do you save it as? Could that be the problem?
The file must be named services-start and not services-start.sh.
The Unix file type you are referring to is the way the line endings end, not the file ending .sh.
In Notepad++ you set it in Edit > EOL Conversion > UNIX Format.
 
thelonelycoder,
The file was created with Unix line endings - it was the file extension. I saved the services-starts file as "All types (.)" in Notepad++ and replaced it in /jffs/scripts and made it executable. On rebooting the router a listing of the cron jobs ("cru l") shows the job listed to run! Thanks to both ColinTaylor and thelonelycoder for helping out a newbie - much appreciated!
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top