Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:22:07+00:00 2026-06-03T14:22:07+00:00

I write a function which sets system time in linux. I write next code:

  • 0

I write a function which sets system time in linux. I write next code:

import time
import subprocess

def SetSystemTime(val):        
    try:
        val = float(val)
    except ValueError:
        return
    command = 'date -s"' + time.ctime(val) + '"'
    subprocess.call(command)

On calling of that i get:

File “crc.py”, line 96, in
SetSystemTime(0)
File “crc.py”, line 12, in SetSystemTime
subprocess.call(command)
File “/usr/lib/python2.7/subprocess.py”, line 493, in call
return Popen(*popenargs, **kwargs).wait()
File “/usr/lib/python2.7/subprocess.py”, line 679, in init
errread, errwrite)
File “/usr/lib/python2.7/subprocess.py”, line 1239, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:22:08+00:00Added an answer on June 3, 2026 at 2:22 pm

    subprocess.call() normally takes a list of strings as its first argument. If you hand it a string X (as you do), that one will be converted to list with that whole string as its first argument.
    The first element of that list is executed with the rest of that list as arguments.
    So the underlying OS tries to execute the executable ‘date -s”XXYYXXZ”‘ and cannot find it.

    This is different from os.system() that hands the parameter to a shell that most often splits the string it gets at the spaces and then executes the first element split off.

    Try:

    command = ['date', '-s"' + time.ctime(val) + '"']
    subprocess.call(command)
    

    as the last two lines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to write a function which takes any other function and wraps a
In C/C++, there is a 'write() function which let me write to either file
I want to write a function which can validate a given value (passed as
How can I write a function which will return pi (π) to a given
How do I write a function which returns true if the string contains at
I would like to write a function which will read values from a text
i am trying to write one function which return sql statement like function get_sql($name=0,$date_start=0,$date_end=0)
I would like to write a function in which there are multiple Exit Function
I need to write a TSQL user defined function which will accept a string
If you have a C function which returns an integer, you could write a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.