Not a problem: I have Cpanel on the server in question, which comes with its own lovely easy-set-up-a-cron-job tool, so I didn't even have to remind myself how to set up a cron job manually. The job I wanted Cron to do was to go and run a file that lives on another server. Cron is not the going-out type himself, but I told him to get his friend Lynx to go and request the file. That meant my instruction (or possibly incantation) to Cron looked like this: 0 8,16 * * * lynx -dump https://www.otherserver.com/myfile.php But alas, the file was password protected. So I had to tell Cron to tell Lynx to use a password , like this :
0 8,16 * * * lynx -auth=user:password -dump https://www.otherserver.com/myfile.php
But my troubles were not over, for the password was not a nice easy one, like 'password'. No, my password was Password!() It turned out that those nasty-looking parentheses and exclamation marks gave poor Lynx awful hiccups. So I had to encode the nasty characters so that Lynx would not be upset by them, like this:
0 8,16 * * * lynx -auth=user:Password%21%28%29 -dump https://www.otherserver.com/myfile.php
Was this all the information Cron needed? Apparently not. If I told Lynx what to do direct, she was most obedient, but Cron became obstrepherous when asked to instruct Lynx and said : "Error opening terminal: 21. Your Terminal type is unknown!" Perhaps I'm overreacting, but that sounds pretty damn sarcastic to me. Cron might as well have added 'You Idiot!'. I thought what he meant was: you expect me to talk to this strange bint Lynx? Never heard of her! No idea where she lives! So I tried again, giving him Lynx's full address so he had no excuse for pretending he couldn't find her, like this :
0 8,16 * * * /usr/bin/lynx -auth=user:Password%21%28%29 -dump https://www.otherserver.com/myfile.php
But did Cron obey? He did not. He continued to witter on about Terminals. Then I thought - hmm, this cunning Cpanel thing that I'm using to give Cron instructions. Does he mean that the user doesn't have permission to talk to him? But no. It was not that: I set it up manually but no joy. And it wasn't that the user didn't have permission to run cron jobs either, for I went back and set it up as root, and that didn't work either. Woe.
Looking at the logs, my helpful host discovered that although running
/usr/bin/lynx -auth=user:Password%21%28%29 -dump https://www.otherserver.com/myfile.php from the commandline worked like a dream, for some reason, Cron got upset when he encountered the % character.
It upset him so much that he was only sending Password to Lynx, not Password!() So, I went back again, and tried this instead : 0 8,16 * * * /usr/bin/lynx -auth='user:Password!()' -dump https://www.otherserver.com/myfile.php using the single quotes as a sort of insulation to hide the scary exclamation mark and brackets from delicate souls who might otherwise be traumatised by them.
And it worked! Happy dance.
Now this may not be a much of a quest if you are the kind of person who frolics merrily along the command line like a spring lamb, frisking your tail, but this is the kind of thing I do once in a blue moon. So now I have notes, and with a bit of luck, next blue moon I can do it again quicker, and what's more, so can anyone else out there who happens to be googling for it.