Windows 10: Running scheduled jobs e.g hourly on Linux VM / WSL / Host Linux

Discus and support Running scheduled jobs e.g hourly on Linux VM / WSL / Host Linux in Windows 10 Virtualization to solve the problem; Hi folks for those who have NAS (Linux) type servers / Linux VM's or Host Linux systems it's dead easy to set up jobs that run say every hour or... Discussion in 'Windows 10 Virtualization' started by jimbo45, Jan 2, 2020.

  1. jimbo45 Win User

    Running scheduled jobs e.g hourly on Linux VM / WSL / Host Linux


    Hi folks

    for those who have NAS (Linux) type servers / Linux VM's or Host Linux systems it's dead easy to set up jobs that run say every hour or whatever - use for this would be scheduled backups etc etc.

    I've got a simple 1 line example here of running an email to myself every hour --simply sends my external IP address -- so I can logon remotely to server even if ISP changes the IP address (which they often do --rare to be given ISP static internet addresses). That way I don't need dyndns, teamviewer or other things like that but there's all sorts of commands you can schedule to run --backups would be one that immediately seems obvious to me - but always best to start simple !!!

    Create your executable bash / script file say in home directory and then link it to /usr/local/bin (via the ln command)
    and now create an entry in crontab (you can be a normal user - doesn't need admin or root privileges to edit your own crontab)

    first the actual email command (but can be any script / job you like) (for dig command install packages dnsutils and netcat)
    note BASH expects the #!/bin/bash in the ist line even though # is a comment line

    #!/bin/bash
    # Send email from bash
    # hrafn simple script to send simple email with your IP address (external)
    server="<email server>"
    port="<port>" ===< assume 25 -- this is for standard not auth not tls etc
    from="<your email address>"
    to="<email of receiver>"
    # get your public IP address
    myip="$(dig +short myip.opendns.com @ReSolver1.opendns.com)"
    # create message
    function mail_input {
    echo "ehlo $(hostname -f)"
    echo "MAIL FROM: <$from>"
    echo "RCPT TO: <$to>"
    echo "DATA"
    echo "From: <$from>"
    echo "To: <$to>"
    echo "Subject: Internet Addressl"
    echo " "
    echo "Your public internet address is "
    echo $myip
    echo " "
    echo "finished"
    echo "."
    echo "quit"
    }

    mail_input | netcat $server $port || err_exit

    save as a .sh type of file and make executable and ln to /usr/local/bin

    Don't forget the echo "." line --not a typo this indicates to the mail server that it's end of input data stream.

    now the crontab table 1 line is all that's needed --google for crontab entries -- this is the simplest -run this job every hour on the hour 7 days a week. You can make much more specific - by time, by day by date etc etc.

    0 * * * * /usr/local/bin/automail

    SEEEMPLES !!"!!

    works in WSL as well

    If you need more complex email authorisations, attachments and password authentication etc it's easy to do -- beyond the scope of this post which was simply to show how easy it is to schedule any jobs you might want on NAS type server or if using the WSL on Windows.

    Update : Here's the mail that arrived in Outlook inbox at 14.00 (scheduled via the crontab) - approx 20 mins after I made this post.


    Running scheduled jobs e.g hourly on Linux VM / WSL / Host Linux [​IMG]


    Happy new year and "Cronning"

    Cheers
    jimbo

    :)
     
    jimbo45, Jan 2, 2020
    #1
  2. jimbo45 Win User

    Windows HOST, attach Linux external USB to Linux VM


    Hi there

    I usually run a LINUX HOST for testing Windows VM's - but I need to test some new releases of various Linux distros so I've created some VM's --easy enough and running them on a Windows Host.

    However I can't attach a USB drive with a Linux file system (XFS) to the VM as the Windows HOST rejects the HDD wanting me to format it !!. There's 2.7 TB of media files on it - I want to test running media server in a VM.

    Anybody know how to bypass the Windows nag prompt about the HDD and be able to attach it direct to the VM.

    (The other way round is no problem -- never a problem loading NTFS HDD's on to Linux machines -- however the NTFS file system is SLOW compared with XFS -- on USB3 device on Native windows transfer rate of 1 TB of files from fast NTFS HDD to NTFS USB3 device is max 82 Mib/s - average for whole transfer. On same machine with Native Linux and XFS to XFS (using same HDD's and USB 3 port avg speed is 350 mib/s !! -- HUGE difference !!!).

    Note I have to have a Windows Host for this --I know I could run Linux VM's from a Linux Host but in this case I do have to use a Windows Host as that will be the destination system at the end of testing.

    BTW I'm running VMWARE workstation 12.1 on W10 Pro Host.

    Cheers
    jimbo
     
    jimbo45, Jan 2, 2020
    #2
  3. cereberus Win User
    Windows HOST, attach Linux external USB to Linux VM


    Not a direct solution but wouldn't it work if drive was formatted as exFAT instead which can be read or written on Linux (may need to add support).

    Perhaps putting a small fat 32 partition on drive so you can get drive mounted in vm, and then use tools in vm to read xfs partitions might work?
     
    cereberus, Jan 2, 2020
    #3
  4. Running scheduled jobs e.g hourly on Linux VM / WSL / Host Linux

    Windows Subsystem Linux

    Hello,

    We would like to know more about the issue you're experiencing with using
    Windows Subsystem for Linux
    . Kindly answer the following questions:

    • Are you developing a program, an app, or a software for Linux?
    • Is your Window 10 PC connected to a domain?
    • Are you managing a Windows Server PC?
    • What troubleshooting steps have you tried so far?
    • Can you tell us the Version and OS build of your Windows 10 device? You can find this information by clicking the
      Start button, type About your PC, and then press
      Enter.

    We need the following information in order to determine if we need to refer your concern to the
    TechNet forums or the Microsoft Developer Network (MSDN) forums.

    For now, we suggest reviewing these support articles to find out if there's an issue with the installation of
    Windows Subsystem for Linux:


    We'll be waiting for your response.
     
    Devlin Sco, Jan 2, 2020
    #4
Thema:

Running scheduled jobs e.g hourly on Linux VM / WSL / Host Linux

Loading...
  1. Running scheduled jobs e.g hourly on Linux VM / WSL / Host Linux - Similar Threads - Running scheduled jobs

  2. Bridged networking to Windows VM from linux host

    in Windows 10 Network and Sharing
    Bridged networking to Windows VM from linux host: Hi folks I created a working bridge to a physical NIC as per : [[email protected] hrafn]# ifconfig enp2s0f1 0.0.0.0 [[email protected] hrafn]# brctl addbr br0 [[email protected] hrafn]# brctl addif br0 enp2s0f1 <==== one of my NIC physical interfaces - [[email protected]...
  3. RAID 0 on linux kernels >5.3.3 (Hosts and VM's)

    in Windows 10 Virtualization
    RAID 0 on linux kernels >5.3.3 (Hosts and VM's): Hi folks for those using RAID 0 especially on devices with unequal sizes you won't be able to access your array after kernel 5.3.3 (whether as host or in a VM) This applies whatever the Windows Host virtualisation you are using - whether VBOX / VMWare or HYPER-V. Also...
  4. WSL and Linux apps

    in Windows 10 Software and Apps
    WSL and Linux apps: Hey there Linux enthusiasts! I wonder what you think about this Windows Subsystem for Linux and which apps you installed. I installed openSUSE from Microsoft store (sounds weird right? *Biggrin) just to check the feature out. So far I can only play around with Linux commands...
  5. Linux VM's / hosts using deluge torrent client fix

    in Windows 10 Virtualization
    Linux VM's / hosts using deluge torrent client fix: Hi folks if you use python 3 on Linux VM's and use deluge as your torrent client you will need to install python3-cairo or it won't start. If you get message in other python stuff with module cairo not found this error should be fixed by the install. Also make sure...
  6. Windows HOST, attach Linux external USB to Linux VM

    in Windows 10 Virtualization
    Windows HOST, attach Linux external USB to Linux VM: Hi there I usually run a LINUX HOST for testing Windows VM's - but I need to test some new releases of various Linux distros so I've created some VM's --easy enough and running them on a Windows Host. However I can't attach a USB drive with a Linux file system (XFS) to...
  7. Unrar - extract / list .RAR files in Linux (VM or Host)

    in Windows 10 Virtualization
    Unrar - extract / list .RAR files in Linux (VM or Host): Hi there. some of you running Linux VM's might want to be able to UNRAR some RAR files directly in Linux without having to access the files on your Windows system and extract / view via 7Z or other programs. Other types of archives such as zip etc are usually managed by...
  8. Running Linux VM on HYPER - V --works !!!

    in Windows 10 Virtualization
    Running Linux VM on HYPER - V --works !!!: Hi there @Kari particularly -- any experience with using the FREE 2016 server HYPER-V edition and any pitfalls as I want to try it later. Try Active Microsoft Hyper-V Server 2016 | TechNet Evaluation Software Best Practices for running Linux on Hyper-V | Microsoft...
  9. VLC on W10 VM on Linux Hosts (Workstation 12.1 - Fixed

    in Windows 10 Virtualization
    VLC on W10 VM on Linux Hosts (Workstation 12.1 - Fixed: Hi there. on some Linux Hosts using Vmware workstation / Player VLC doesn't work properly on a Windows 10 VM - you don't get any dropdowns from the menu. A reasonable fix for this (apart from checking that you have any Video drivers installed for your Host system) is to...
  10. 1607 - no Wifi on HOST but Linux VM has no problem with Internet !!!

    in Windows 10 Network and Sharing
    1607 - no Wifi on HOST but Linux VM has no problem with Internet !!!: Hi there after no problem with all the various updates on Windows 1607 I've really got a strange one now Laptop (HP envy) has lost Wifi and Internet connectivity on the Windows HOST - but a Linux VM I'm running on the same laptop has absolutely NO problem connecting to...