0

This question already has an answer here:

I am trying to make a script that switches files at different times of days so that my settings are pulled at different times like a day mode and a night mode.

If I have a file 1, 2, and 3 which 3 is a group of settings for my server. I want to switch out 1 to become 3 from 8am to 6pm. then I want 2 to become 3 from 6pm to 8am automatically. How can I do this though shell script? I just want to basically do a cp -v 1 3 then cp -v 2 3 on a schedule how would I accomplish this? thanks in advance! I don't want to do it through cron i want to do it through shell script only, if possible!!

marked as duplicate by muru, wjandrea, Terrance, Zanna, Eric Carvalho Mar 10 '18 at 12:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Why not through cron? – muru Mar 9 '18 at 2:05
  • If not via cron, then: askubuntu.com/q/844533/158442 – muru Mar 9 '18 at 2:07
  • 1
    Yes you can do it via script only; the script sleeps for xx hours on a cycle, but why? cron is more resource efficient. You realize if you switch configs, whatever processes using them will probably need restart (to read the altered config) as they'll likely be reading/using the old config (inode) – guiverc Mar 9 '18 at 2:10
  • Because I'm trying to make it a self contained shell script that i can save on various servers and just run the shell when I want from putty real quick. It is a random thing. More detail on what im doing is running a Zcash miner in ubuntu. and one pool pays good when it finds block but rarely finds blocks so when i see its been 24-48 hours since they've found a block i just want to run the script and switch pools. Because generally once they got that long without a block they are close to finding on and then i wanna switch back to my more steady pay out pool after say 12 hours – Colt Burdine Mar 9 '18 at 2:14
  • If you guys think cron is the way to go still ill do it and yes the process needs to be restarted but i know how to restart it in the script when the script runs. – Colt Burdine Mar 9 '18 at 2:15

Browse other questions tagged or ask your own question.