LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   hostname in crontab (https://www.linuxquestions.org/questions/linux-newbie-8/hostname-in-crontab-4175601071/)

sainoh 03-04-2017 01:38 PM

hostname in crontab
 
Hi,
I am a total Linux Newbie, so this might be (too) easy for you :)
I am running a Synology NAS and have to replace an IP address in crontab by the dyndns hostname

crontab looks like:
20 4,16 * * * root /bin/dl-lesenx -i 192.178.55.22:40000 --res --dir /volume1/public/transfer/

how can I replace IP address:Port by hostname:Port ?

txs

Charlie

RandomTroll 03-04-2017 02:27 PM

Code:

crontab -e
is how you edit a crontab file. Note that it runs crontab's default editor, usually ed. If you don't want to deal with ed you can change the default editor with an environment variable. Run
Code:

man crontab
for more information.

sainoh 03-04-2017 02:30 PM

I wasn't clear enough, I am afraid

I know how to edit, but can I replace

20 4,16 * * * root /bin/dl-lesenx -i 192.178.55.22:40000 --res --dir /volume1/public/transfer/

by

20 4,16 * * * root /bin/dl-lesenx -i bigboy.selfip.net:40000 --res --dir /volume1/public/transfer/

Habitual 03-04-2017 05:48 PM

edit /etc/hosts,
Code:

192.178.55.22 bigboy.selfip bigboy
then
Code:

ping bigboy.selfip
returns 192.178.55.22
Then you can utilize "poor man's dns".
Code:

20 4,16 * * * root /bin/dl-lesenx -i bigboy.selfip.net:40000 --res --dir /volume1/public/transfer/

RandomTroll 03-04-2017 09:24 PM

Sorry, Mr sainoh: you asked in newbies and told us how simple to expect it to be... Back in the good old days before DHCP I had to keep /etc/hosts so people didn't have to remember IP addresses. Even after I still did it for a while; I forget why. Mr Habitual has the correct answer; there's still fun to be had assigning addresses in /etc/hosts. A forgotten old comedy troupe has some odd videos only available at an IP address (at least that's all Google returned); I added a domain for them in /etc/hosts so I didn't have to remember it.

michaelk 03-05-2017 08:42 AM

The question its still vague. Is 192.178.55.22 a public address or typo?

If the OP is using a dynamic IP service for their public IP address then adding a line to the /etc/hosts file will fail when it changes.

If by dyndns your only referring to your local router DHCP then you should be able to configure any device with a static IP or use the routers address resveration feature which most have these days.

If your asking can you change from an IP address to hostname from a program perspective then it depends on the meaning of the -i option. I am unfamiliar with dl-lesenx.

If your asking can you change from a crontab perspective then yes. Most distributions are configured to use vim and you can find lots of guides on using its commands.


All times are GMT -5. The time now is 05:56 AM.